[英]how to make htaccess force https for www.example.com and example.com but no other subdomains
I have a host that has many subdomains and I want to force https (redirect for https ) for www.example.com and example.com but not any other subdomain, how to do this? I have a host that has many subdomains and I want to force https (redirect for https ) for www.example.com and example.com but not any other subdomain, how to do this?
currently I am using:目前我正在使用:
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
but this does not work as expected但这并没有按预期工作
You can just add a condition using HTTP_HOST
:您可以使用
HTTP_HOST
添加条件:
RewriteCond %{HTTPS} !=on
RewriteCond HTTP_HOST ^(?:www\.)?example\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.