繁体   English   中英

htaccess使用https和子域重定向

[英]Htaccess redirect with https and subdomains

我有htaccess:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301]

要将http重写为https并添加“ www”。 但我也想从我的子域重定向:

http://subdomain.mysite.com => https://www.mysite.com
https://subdomain2.mysite.com => https://www.mysite.com

等等。我该怎么做?

尝试以下方法:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM