[英]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.