假如您的网站是http://ningyuqiao.blog.51cto.com/网站是用wordpres搭建的,则只需要在nginx的配置文件中加入:
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搭建的,则代码需要改成
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,如需转载请自行联系原作者