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