【发布时间】:2015-07-18 22:30:14
【问题描述】:
我如何进入 htaccess 以强制 https 和 www。在域上,& http 在子域上没有 www?
以下将http://sub.domain.com 重定向到https://domain.com
# for main domains
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^.*$ https://www.domain.com%{REQUEST_URI} [R,L]
# for sub domain
RewriteCond %{HTTP_HOST} ^(www\.)?sub\.domain\.com$ [NC]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ http://sub.domain.com%{REQUEST_URI} [R=301,L,NE]
【问题讨论】:
标签: apache .htaccess mod-rewrite subdomain no-www