wordpress nginx 开启链接为静态

使用固定连接里的自定义

/%postname%/

日志标题的缩略版本(日志/页面编辑界面上的日志别名)。因此“This Is A Great Post!”在URI中会变成this-is-a-great-post。

nginx.conf中添加伪静态规则

location / {
if (-f $request_filename/index.html){
                rewrite (.*) $1/index.html break;
        }
if (-f $request_filename/index.php){
                rewrite (.*) $1/index.php;
        }
if (!-f $request_filename){
                rewrite (.*) /index.php;
        }
}

在添加文章或者添加页面的地方,右上方有一个选项,里面有别名,别名输入英文,空格隔开,在生成伪静态的时候,会自动转换为-分隔

参考:

http://blog.sina.com.cn/s/blog_40d47c89010144r4.html

http://www.newwan.net/wordpress%E5%9B%BA%E5%AE%9A%E9%93%BE%E6%8E%A5%E7%9A%84%E8%AE%BE%E7%BD%AE%E6%96%B9%E6%B3%95-%E8%AE%A9nginx%E6%94%AF%E6%8C%81wordpress%E7%9A%84%E5%9B%BA%E5%AE%9A%E9%93%BE%E6%8E%A5.html