Nginx下让WordPress支持伪静态规则及网站下级目录配置伪静态教程

假如您的网站是http://ningyuqiao.blog.51cto.com/网站是用wordpres搭建的,则只需要在nginx的配置文件中加入:

1
2
3
4
5
6
7
8
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://ningyuqiao.blog.51cto.com/blog/网站是用wordpres搭建的,则代码需要改成

1
2
3
4
5
6
7
8
location  /blog  { if  (-f $request_filename /blog/index .html){
                 rewrite (.*) $1 /blog/index .html  break ;
         } if  (-f $request_filename //blog/index .php){
                 rewrite (.*) $1 /blog/index .php;
         } if  (!-f $request_filename){
                 rewrite (.*)  /blog/index .php;
         }
      }

这个配置方法有个bug,正确的方法见http://ningyuqiao.blog.51cto.com/5581274/1616023





      本文转自ning1022 51CTO博客,原文链接:http://blog.51cto.com/ning1022/1615552 ,如需转载请自行联系原作者




你可能感兴趣的:(Nginx下让WordPress支持伪静态规则及网站下级目录配置伪静态教程)