对于Apache和Nginx的对比网上也是一大堆了,这里就不再赘述,以后有机会详细讲解。相信用Wordpress的博主们都会用到伪静态,伪静态的好处是对搜索引擎友好,看起来也好看。用虚拟主机的用户大都是用Apache,Apache的伪静态Wordpress支持...
对于Apache和Nginx的对比网上也是一大堆了,这里就不再赘述,以后有机会详细讲解。
相信用Wordpress的博主们都会用到伪静态,伪静态的好处是对搜索引擎友好,看起来也好看。
用虚拟主机的用户大都是用Apache,Apache的伪静态Wordpress支持很好,几乎不用自己去编辑。喜爱折腾,喜爱独立博主们用VPS 的还是很多的,Nginx在VPS中作为架设环境还是挺常见,但是用Nginx时Wordpress就变成瞎子一般,这里就怎样在Nginx下设置伪静 态。
我们不需要了解怎样写伪静态,不需要了解原理,只需按照下面的方法,你的Wordpress就可以在Nginx下开启伪静态了!Just do IT!
Nginx不需要.htaccess
编辑虚拟主机的nginx.conf(usr/local/nginx/conf/vhost/域名.conf.一定是你的域名的配置文件!),在
server "pun">{ listen ; "pln"> server_name … "pln"> root …
之后添加
location "pun">/ "pun">{ "pln"> index index "pun">.html index "pun">.php "pun">; "kwd">if "pun">(- "pln">f $request_filename "pun">/index "pun">.html "pun">){ "pln"> rewrite "pun">(.*) $1 "pun">/index "pun">.html "kwd">break; "pln"> } "pln"> if "pln"> (- "pln">f $request_filename "pun">/index "pun">.php "pun">){ "pln"> rewrite "pun">(.*) $1 "pun">/index "pun">.php "pun">; "pun">} "kwd">if "pun">(!- "pln">f $request_filename "pun">){ "pln"> rewrite "pun">(.*) "pun">/index "pun">.php "pun">; "pun">} "pun">}
然后再重新加载Nginx:(这个很重要)
/etc/ "pln">init. "pln">d/ "pln">nginx restart //cenots
全文结束,有问题欢迎留言讨论。