htaccess http到带有www的https。不重定向子域 [英] htaccess http to https with www. Without redirecting sub domain
本文介绍了htaccess http到带有www的https。不重定向子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 RewriteRule
,它将我的主域重定向到 https://www.sta-games.com
效果很好,但是当我尝试访问我的子域 http://files.sta-games.com
时,它将重定向到我的主域。
I have a RewriteRule
that redirects my main domain to https://www.sta-games.com
which works fine, but when I try to access my subdomain http://files.sta-games.com
, it redirects to my main domain.
继承我的重定向规则
#HTTPS Redirection
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
有人可以看到问题吗?
推荐答案
所有域都具有附加的跳过条件除了主域名之外,其他域名除外:
Have an additional skip condition for all domains except the main domain:
RewriteCond %{HTTP_HOST} ^(www\.)?sta-games\.com$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.sta-games.com%{REQUEST_URI} [L,R=301,NE]
在清除浏览器缓存后进行测试。
Test this after clearing your browser cache.
这篇关于htaccess http到带有www的https。不重定向子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文