将 HTTPS 重写为 HTTP,但活动证书不起作用
当我输入 http://domain.com 时,我已为域安装了 HTTPS 证书,当我输入 https://domain.com 它不会重定向到 http。 我的 .htaccess 有
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
I have HTTPS certificate installed for domain when i type http://domain.com it works when i type https://domain.com it does not redirect to http.
My .htaccess has
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
RewriteCond
指令将规则限制为以www
开头的域,因此它将与您的domain.com
测试网址不匹配。您可以使用
https://www.domain.com
进行测试或更改如下规则但是,我不喜欢这个解决方案,因为我无法理解每个规则背后的意图,例如您拥有的第二条规则应该会导致无限重定向(假设这些是您的 .htaccess 中的唯一规则)。
如果您解释每条规则的意图,我将能够提供更好的答案
Your
RewriteCond
directive limits the rule to domains starting withwww
so it will not match your test url ofdomain.com
.You can either test with
https://www.domain.com
or change the rule as belowHowever, I don't like this solution because I cannot understand what your intention is behind each of the rules e.g. the second rule you have should cause an infinite redirect (assuming these are the only rules in your .htaccess).
If you explain what your intention is for each rule, I would be able to provide a better answer