服务器引擎从Apache换成Nginx后,Wordpress的rewrite一直是用配置404跳转到index.php的方式实现的。这个最近才发觉,因为www.evoleo.com大部分是原创内容,竟然被百度拔毛的只剩首页了!排除了其他可能后才发觉问题出在404上。所有终于找到了正确的rewrite代码:

location / {
index index.html index.php;
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;
}
}

幸亏发觉的早,不然博客首页都有可能被拔毛。
这也是另外一个wordpress做的博客一直只收录首页的罪魁祸首。两个站的虚拟主机配置都改过了,等百度重新收录吧。

Published in Linux学习笔记

7 Responses to “Nginx下Wordpress实现Rewrite的正确方法”

  1. 02月 25th, 2008 at 11:56 #evoleo

    百度已经重新收录博客,现在基本正常~

  2. 06月 12th, 2008 at 8:50 #online glücksspiel

    online glücksspiel...

    rolled lot sulfurous?casino [url=http://www.onlinekingsolomonspoker.com/casino.html]casino[/url] http://www.onlinekingsolomonspoker.com/casino.html ...

  3. 06月 13th, 2008 at 12:01 #intercasino

    intercasino...

    interpolate raindrops screams intermingles supervising ...

  4. 08月 6th, 2008 at 10:54 #hao32

    后台似乎有问题~~~

  5. 10月 3rd, 2008 at 2:54 #pro health care speeches

    pro health care speeches...

    eleventh succession Bologna?gallantly ...

  6. 11月 6th, 2008 at 5:43 #pokar de données

    pokar de données...

    sadistically:conduct deluged blade ...

  7. 11月 8th, 2008 at 2:45 #www bet fair pokernet

    www bet fair pokernet...

    prompts adders event ...

Leave a Reply