2015-04-01 16 views
0

目前,我在htaccess中設置了下列重定向,以將www和非www URL重定向到使用www的HTTPS。如何停止子域的HTTPS重定向

RewriteCond %{HTTP_HOST} ^example\.com$ 
RewriteRule ^(.*) https://www.example.com/$1 [R=301,L] 
RewriteCond %{HTTPS} !on 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

我現在已經創建了一個子域dev.example.com。但是當我運行它時,站點重定向到使用www的HTTPS。我怎樣才能阻止它,並沒有任何重定向加載開發?

回答

0

添加另一個條件到HTTPS規則:

RewriteCond %{HTTP_HOST} ^example\.com$ 
RewriteRule ^(.*) https://www.example.com/$1 [R=301,L] 

RewriteCond %{HTTP_HOST} !dev\.example\.com$ [NC] 
RewriteCond %{HTTPS} !on 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]