.htaccess强制子域的http
我已将我的主站点设置为使用https。我强迫用户使用.htaccess访问https。我使用这个代码.htaccess强制子域的http,.htaccess,ssl,mod-rewrite,https,apache2,.htaccess,Ssl,Mod Rewrite,Https,Apache2,我已将我的主站点设置为使用https。我强迫用户使用.htaccess访问https。我使用这个代码 RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR] RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(www\.)?(.+) Rewrit
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
但是我有一个子域名。这被称为xxx
。它的内容位于/xxx
。如何强制xxx.domain.com仅使用http?您可以使用此选项
RewriteEngine on
#redirect www urls to non-www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# do nothing if sub.domain.com is requested
RewriteCond %{HTTP_HOST} ^sub.domain.com$
RewriteRule ^ - [L]
#redirect the main domain to https
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
测试此项之前,请清除浏览器缓存