2016-11-28 170 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] 
相关问题