2011-10-14 38 views

回答

2

試試這個:

RewriteEngine On 

# redirect all www (http or https) to https://domain.com 
RewriteCond %{HTTP_HOST} ^www.domain.com [nc] 
RewriteRule (.*) https://domain.com:80/$1 [R=301,L] 

# redirect http://domain.com to https://domain.com 
RewriteCond %{HTTP_HOST} ^domain.com [nc] 
RewriteCond %{HTTPS} !=on 
RewriteRule (.*) https://domain.com:80/$1 [R=301,L] 

# redirect all sub domain (http or https) to https://domain.com 
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.domain\.com$ [NC] 
RewriteCond %1 !^www$ [NC] 
RewriteRule (.*) https://domain.com:80/$1 [R=301,L] 
+0

我開始發現這是不可能的,由於SSL被用來重寫規則之前被驗證。我可能在這方面是錯誤的,但無論哪種方式我都可以處理它,這更多的是方便而不是必要。謝謝。 – turkoid