htaccess的重定向HTTPS访问http不工作 [英] .htaccess redirect https to http not working

查看:173
本文介绍了htaccess的重定向HTTPS访问http不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想捕捉任何HTTPS流量到我的网站的前面,这样:

I am trying to catch any https traffic to the front of my site so:

https://www.domain.com

被重定向到:

is redirected to:

http://www.domain.com

然而,其他子域需要被重定向到其他地方。在大多数情况下,这是所有工作,除了HTTPS - > HTTP重定向。下面是目前我的.htaccess文件:

However other subdomains need to be redirected elsewhere. For the most part this is all working, apart from the https -> http redirection. Here's my .htaccess file at the moment:

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]

这似乎是这一点:

It would seem that this bit:

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

不工作,我会想象。事实上,它似乎并没有重定向的。

isn't working as I would imagine. In fact it doesn't seem to redirect at all.

在另一个子目录我有相反的有效工作正常:

In another subdirectory I have the opposite in effect which works fine:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

所以我的想法是相反的应该做的工作,但似乎并非如此。

so my thinking is the opposite should have done the job, but seemingly not.

任何想法的人?

修改

我在想,这可能是与一个事实,即在服务器上有它的ISP用于提供一个通用的https地址到你的网站的SSL证书。例如,如果你在有一个网站:

I'm thinking that this could have something to do with the fact that on the server there is an ssl cert which the ISP uses to provide a generic https address to your site. For example if you have a site at:

http://www.yourdomain.com

您可以通过访问相同的内容/主机通过HTTPS帐户:

You can access the same content/hosting account over https by using:

https://server100.securedomain.com/yourdomain.com

难道是因为当我在输入https到浏览器中,我所服务的通用证书,并因为它不匹配的域名我输入我收到关于不受信任的证书安全警告,这正在停止重定向?

Could it be that because when I type in https into the browser I'm being served the generic cert and because it doesn't match the domain name I've entered I'm getting a security warning about an untrusted cert which is stopping the redirection?

编辑2

纵观服务器头我想我是正确的与我上面的假设。服务器返回的:

Looking at the server headers I think I am correct with my above assumption. The server is returning:

The host name in the certificate is invalid or does not match

这会停止重定向?

Would this stop the redirection?

推荐答案

刚刚意识到,我从来没有关闭这个功能,所以对任何人的利益,否则试图解决这个我会了。

Just realised that I never closed this off, so for the benefit of anyone else trying to solve this I will now.

总之,捕获所有HTTPS - > HTTP重定向,我是想实现将无法工作,因为服务器提供了证书第一,然后将生成的安全警告。出现这种情况的重定向显而易见的安全原因之前,因此重定向不工作一个我想要的。

In short, the catch all https -> http redirection that I was trying to achieve won't work because the server is serving up the cert first which is then generating the security warning. This happens before the redirect for obvious security reasons, hence the redirect not working a I wanted.

希望有所帮助别人。

这篇关于htaccess的重定向HTTPS访问http不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆