我一直在试图管理从www.domain.com到domain.com, 的重定向,但似乎没有任何效果。 我总是得到一个重定向循环 - 我尝试了各种在Google或Google上找到的东西。htaccess无重定向问题www
所以这里是我的.htaccess,也许有人可以帮我弄清楚我能做些什么来正确重定向,或者如果在这里有什么问题。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
# Redirect all to .php
# Example: example.com/hello -> example.com/hello.php
RewriteRule ^(.*)$ $1.php [L,R=301]
# show example.com/index.php always as example.com/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://example.com/ [R=301,L]
非常感谢! 我已经花了很多时间试图弄清楚这一点。
非常感谢! 随着你的第二个RewriteCond&RewriteRule,它再次给了我循环,但如果我把它放开,它就可以工作。 谢谢! – rafleo 2010-07-08 09:33:09
没问题。如果你需要第二部分不工作(对此感到抱歉),我继续进行更新,以便处理那些也会导致问题的边缘情况(尽管我没有完全清醒,所以可能会有更多的我没有考虑)。 – 2010-07-08 09:36:40