简体   繁体   English

为什么.htaccess忽略“[NC]上的RewriteCond%{HTTPS}!”?

[英]Why is .htaccess ignoring “RewriteCond %{HTTPS} !on [NC]”?

Since I declare it should only redirect if it is NOT an "https://" request, this code should not redirect from index.rd1.html to index.rd2.html if I type " https://example.com/index.rd1.html " in the url, but it does. 由于我声明它只应重定向,如果它不是“https://”请求,如果我输入“ https://example.com/index ,则此代码不应从index.rd1.html重定向到index.rd2.html .rd1.html “在网址中,但确实如此。 Why? 为什么?

RewriteEngine On
RewriteCond %{HTTPS} !on [NC]
RewriteCond %{REQUEST_URI} index.rd1.html [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/index.rd2.html [R=301,L]

It turns out that hostway.com (which is hosting the site) does not have the standard .htaccess rules. 事实证明,hostway.com(托管该网站)没有标准的.htaccess规则。 In order for it to detect https I had to add "ENV:" before HTTPS as done here: 为了检测https,我必须在HTTPS之前添加“ENV:”,如下所示:

RewriteCond %{ENV:HTTPS} !=on

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM