简体   繁体   English

htaccess使用https和子域重定向

[英]Htaccess redirect with https and subdomains

I have htaccess: 我有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]

To rewrite http to https and also add "www". 要将http重写为https并添加“ www”。 But i would like to have also redirect from my subdomains: 但我也想从我的子域重定向:

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

etc. How can i do this? 等等。我该怎么做?

Try this instead: 尝试以下方法:

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