gpt4 book ai didi

.htaccess 为子域强制 http

转载 作者:太空宇宙 更新时间:2023-11-03 13:22:00 26 4
gpt4 key购买 nike

我已将我的主站点设置为使用 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]

在测试之前清除浏览器缓存。

关于.htaccess 为子域强制 http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48264173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com