2016-11-28 121 views
0

我有兩個網站htaccess的力HTTPS和WWW到非www,但子域中的HTTPS

  1. yourdomain.com
  2. reseller.yourdomain.com

現在我想迫使這兩個域使用https通過Apache htaccess重定向。除此之外,主域應始終使用www而非非www。但子域reseller.yourdomain.com當然不應該使用www。

重定向應該怎麼樣?我試圖像

RewriteEngine on 
RewriteCond %{HTTPS} !^on 

RewriteCond %{HTTP_HOST} !^reseller\.yourdomain\.com [NC] 

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

這工作不是100%這麼多東西,主域名正確重定向到WWW和SSL中,SSL重定向爲subomdain只適用於reseller.yourdomain.com,而不是子網站像reseller.yourdomain.com/single-page。

謝謝!

+0

讀到這裏,我可以牽你的答案:http://stackoverflow.com/questions/20894947/force-https-and-www-for-domain-and-只有https-for-subdomains-htacess – andrew

+0

does not work :-(subdomain reseller.yourdomain.de redirects on the maindomain。 – user6573193

回答

0

嘗試像這樣,

RewriteEngine on 
RewriteCond %{HTTPS} !=on 
RewriteCond %{HTTP_HOST} ^yourdomain.com 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301] 

RewriteCond %{HTTPS} !=on 
RewriteCond %{HTTP_HOST} ^(.+)\.yourdomain.com$ 
RewriteRule^https://%1.yourdomain.com [R=301,L] 
相關問題