2016-06-14 75 views
1

我們已經具有服務器2個域重定向HTTP到HTTPS爲多個域

1)exmaple.co

2)exmaple.com.au

如果用戶點擊第一結構域「example.co 「

http://www.exmaple.cohttp://exmaple.co那麼就應該重定向到

https://exmaple.co

如果用戶點擊第二個域 「example.com.au」

http://www.exmaple.com.au OR http://exmaple.com.au那麼它應該是 重定向到

https://exmaple.com.au

我們有購買SSL。

我們有使用框架Codeigniter在htaccess中設置編碼。

RewriteCond %{HTTP_HOST} ^exmaple.co [NC] 

RewriteRule ^(.*)$ http://exmaple.co/$1 [L,R=301] 

RewriteCond %{HTTP_HOST} ^exmaple.com.au [NC] 

RewriteRule ^(.*)$ http://www.exmaple.com.au/$1 [L,R=301] 

如果我使用上面的代碼,那麼它會進行重定向循環。

回答

0

您正在獲得無限的重定向循環,因爲您並未阻止重定向發生。

要達到什麼樣的你正在嘗試做的:

RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^(www\.)?example\.co$ 
RewriteRule ^(.*)$ https://example.co/$1 [L] 

RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com\.au$ 
RewriteRule ^(.*)$ https://example.com.au/$1 [L]