【发布时间】:2016-06-03 12:53:04
【问题描述】:
我希望这样做:
强制我的主域使用 https。
http 到https://www。 http://www 到 https://www。
但不适用于子域
http://subdomain.domain.com 到 https://subdomain.domain.com
谁能帮帮我,我找不到这个
【问题讨论】:
我希望这样做:
强制我的主域使用 https。
http 到https://www。 http://www 到 https://www。
但不适用于子域
http://subdomain.domain.com 到 https://subdomain.domain.com
谁能帮帮我,我找不到这个
【问题讨论】:
你可以在你的根.htaccess中使用它:
RewriteEngine on
# redirect to https www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)(domain\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
# redirect to http subdomain
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^((?!www).+\.domain\.com)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
[编辑]
RewriteEngine on
# redirect no-www to www only main domain, not with subdomain
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
# redirect http to https all domain
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
【讨论】:
index.php 怎么办?