2011-09-14 46 views
0

我使用.htaccess文件強制所有「example.com」請求「www.example.com」htaccess的重寫規則允許的地方發展

的問題是,現在我想開發我的網站在我的機器上本地化,而且我使用的是定義爲example.local的自定義主機 - 指向我本地MAMP堆棧上的網站版本。

#force non-www to www.example.com 
    RewriteCond %{HTTP_HOST} !^www.example.com$ 
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301] 

我該如何修改這個htaccess文件來不把我的example.local請求推送到www.example.com?

回答

1

添加第二個條件,你重寫規則

#force non-www to www.example.com 
RewriteCond %{HTTP_HOST} !^www.example.com$ 
RewriteCond %{HTTP_HOST} !^example.local$ 
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]