我正在尝试捕获到我的网站前面的任何 https 流量,因此:
https://www.domain.com
被重定向到:
http://www.domain.com
然而,其他子域需要重定向到其他地方。在大多数情况下,除了 https -> http 重定向之外,这一切都有效。这是我目前的 .htaccess 文件:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
RewriteCond "%{HTTP_HOST}" !^www.* [NC]
RewriteCond "%{HTTP_HOST}" ^([^\.]+).*$
RewriteRule ^(.*)$ https://secure.domain.com/a/login/%1 [L,R=301]
看来这一点:
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
没有像我想象的那样工作。事实上,它似乎根本没有重定向。
在另一个子目录中,我的效果相反,效果很好:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
所以我的想法是相反的,应该完成这项工作,但似乎没有。
有人有什么想法吗?
EDIT
我认为这可能与服务器上有一个 ssl 证书有关,ISP 使用该证书为您的站点提供通用 https 地址。例如,如果您有一个网站:
http://www.yourdomain.com http://www.yourdomain.com
您可以使用以下命令通过 https 访问相同的内容/托管帐户:
https://server100.securedomain.com/yourdomain.com https://server100.securedomain.com/yourdomain.com
难道是因为当我在浏览器中输入 https 时,我正在获得通用证书,并且因为它与我输入的域名不匹配,所以我收到了有关不受信任的证书的安全警告,该警告正在停止重定向?
EDIT 2
看看服务器标头,我认为我的上述假设是正确的。服务器正在返回:
The host name in the certificate is invalid or does not match
这会停止重定向吗?