Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess强制子域的http_.htaccess_Ssl_Mod Rewrite_Https_Apache2 - Fatal编程技术网

.htaccess强制子域的http

.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

我已将我的主站点设置为使用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\.)?(.+)
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]
测试此项之前,请清除浏览器缓存