Nginx下Wordpress的永久链接实现

经过多番测试,终于在nginx下实现了rewrite的功能,WrodPress的永久链接终于生效了。

其实也是很简单的方法,修改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;
}
}

输入killall -HUP nginx     重启nginx就可以了。

随机日志

4 Comments

  1. Posted 2010年06月12日 at 12:55 上午 | Permalink

    做个记号
    win主机下文章页url的/index.php/不知怎么去掉

    回复

    老白 回复:

    在设置那里的固定链接里 设置自定义url /%category%/%postname%/ 就可以了 都一样的 这个不分主机的

    回复

  2. 杨栋
    Posted 2010年06月21日 at 10:26 上午 | Permalink

    我也来做个记号,以后见面了….嘿嘿

    回复

  3. Posted 2010年06月22日 at 3:28 上午 | Permalink

    老白也开博了哈, 要勤更新哟, 做个友情链接吧

    回复

    老白 回复:

    兄弟 不好意思 太忙了 博客才恢复一点~ 我天生就懒~ 要做 咱做度谷SEO 那个门户的 以后多支持 博客我会抽时间更新恢复的

    回复

  4. Posted 2010年07月13日 at 4:56 上午 | Permalink

    呵呵,发现老白的博客了,最近在研究Linux vps 还是服务器?

    小彭也在… 过来支持下,要求多更新。。。

    回复

    老白 回复:

    呵呵 linux下的nginx咯 很久了 年初的时候了 博客还没时间搞 兄弟们见谅

    回复

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*