2011-05-11 76 views
5

我想重定向多個域到單個域(這是工作正常) 但我想要一個目錄不重定向或更改主域網址。重定向多個域到除1目錄使用htaccess的另一個域

這裏是我的.htaccess的代碼,它工作正常,直到這裏

這一項工作

 
    RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.com$ [OR] 
    RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.net$ [OR] 
    RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.org$ [OR] 
    RewriteCond %{HTTP_HOST} ^domain.info$ [OR] 
    RewriteCond %{HTTP_HOST} !^www.domain.info 
    RewriteRule (.*) http://www.domain.info/$1 [R=301,L] 

全當我試圖阻止一個特定目錄的重定向代碼

 
    RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.com$ [OR] 
    RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.net$ [OR] 
    RewriteCond %{HTTP_HOST} ^http(s)?://(www.)?domain.org$ [OR] 
    RewriteCond %{HTTP_HOST} ^domain.info$  [OR] 
    RewriteCond %{HTTP_HOST} !^www.domain.info [OR] 
    RewriteCond %{REQUEST_URI} !^/no_redirect_dir/ 
    RewriteRule (.*) http://www.domain.info/$1 [R=301,L] 

這一切都停止工作:(與頁面無法正確重定向的錯誤。

額外的代碼導致錯誤

 
    RewriteCond %{HTTP_HOST} !^www.domain.info [OR] 
    RewriteCond %{REQUEST_URI} !^/no_redirect_dir/ 

任何幫助,將不勝感激。

謝謝!

回答

8

寫你的.htaccess這樣的:

RewriteCond %{HTTP_HOST} (www\.)?domain\.(org|net|com)$ [NC] 
RewriteCond %{REQUEST_URI} !^/*no_redirect_dir/ [NC] 
RewriteRule ^(.*)$ http://www.domain.info/$1 [R=301,L] 

HTTP_HOST變量只是有域名,HTTP/HTTPS信息。

相關問題