0
使用.htaccess重定向index.php,index.html和非www变体到www根的最简单方法是什么?例如重定向最简单的Htaccess重定向index.php/html和非www www Root
http://example.com/index.php
http://www.example.com/index.html
http://example.com
使用.htaccess重定向index.php,index.html和非www变体到www根的最简单方法是什么?例如重定向最简单的Htaccess重定向index.php/html和非www www Root
http://example.com/index.php
http://www.example.com/index.html
http://example.com
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
它看起来不像是将index.html和index.php重定向到root?或者我错了? – moteutsch 2011-05-19 15:39:45
是的。 $ 1反向链接到尾部斜线后的任何内容。 – 2011-05-19 15:41:11
啊,对不起,再次阅读我可以看到你的意思。如果您明确想从特定页面重定向,则只需添加另一个“重写规则”。但是,如果'index.html'设置为默认页面,那么它无所谓,它仍然会在同一个地方。 – 2011-05-19 15:43:18