我想重定向index.php,以及任何其他有效的默认文件(例如index.html、index.asp等)。到文档根目录(其中包含index.php),其内容如下:
RewriteRule ^index\.(php|htm|html|asp|cfm|shtml|shtm)/?$ / [NC,L]然而,这当然给了我一个无限的重定向循环。怎么做才是对的?
如果可能的话,我希望在开发和生产环境中都有这样的工作,所以我不想将像http://www.mysite.com/这样的显式url指定为目标。
谢谢!
发布于 2010-04-21 18:13:16
我觉得像这样的东西应该管用。跑去开会,所以我没有时间去测试它,但基本上您必须设置条件以避免重定向主www.site.com/index.php
RewriteEngine On
RewriteCond !^/index.php
RewriteRule ^index\.(php|htm|html|asp|cfm|shtml|shtm)/?$ / [NC,L]发布于 2010-04-21 18:18:37
您可以尝试301重定向它。这在理论上应该是搜索引擎友好的。
RewriteRule ^index\.(php|htm|html|asp|cfm|shtml|shtm)/?$ / [R=301,L]https://serverfault.com/questions/134553
复制相似问题