Apache HTTPS 到 HTTPS 重定向
我们有一个客户端服务器,使用 Apache 2.2 和 Apache 2.2 托管我们的 Web 应用程序。 RHEL 中的 Tomcat 6。我已经为 http 到 https 重定向设置了 apache 重写规则,并且工作正常。我们有两个用于访问同一应用程序的 DNS 名称。 Test1.com 和 Test2.com。我希望所有尝试访问 http://test1.com 或 https://test1.com 的用户都访问 https://test2.com。如前所述,http://test1.com 到 https://test2.com 重定向工作正常。我无法将 https://test1.com 实施为 https://test2.com。
我尝试过虚拟主机、ServerAlias、NameVirtualHost,但没有任何效果。如果我们可以通过重写来处理这个问题,任何建议都会有所帮助。任何可能导致解决此问题的其他指示将不胜感激。
谢谢
We have a client server hosting our web application using Apache 2.2 & Tomcat 6 in RHEL. I have setup apache re-write rule for http to https redirection and it works fine. We have two DNS names that are used to access the same application. Test1.com and Test2.com. I want all the users trying to access http:// test1.com or https:// test1.com to https:// test2.com. As mentioned, http:// test1.com to https:// test2.com redirection is working fine. I am not able to implement https://test1.com to https://test2.com.
I have tried Virtual Hosts, ServerAlias, NameVirtualHost, but nothing works. Any suggestions if we can handles this via re-write would help. Any other pointers that might lead to the resolution of this issue will be appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我通过重定向解决了这个问题,但我必须使用所有必要的 ssl 设置为 https 重定向设置虚拟主机。
I solved this issue with redirect, but I had to setup virtual host for https redirect with all necessary ssl settings.
请尝试以下操作:
如果
:80
和:443
都有一个
,则此重定向应该在两种配置中进行。Try the following:
If you have a
<VirualHost>
for both:80
and:443
, this redirect should go in both configurations.我有带有 https(证书)的 site1 和带有 http(无证书)的 site2,两者都位于同一 IP(虚拟主机)上。
然后我注意到 Google 使用 site1 的内容错误地为 site2 建立了 https 索引。
当 RewriteCond 监听
位于 site2 的 .htaccess 中,
位于 site1 的 .htaccess 中。
但随后区分不再是通过端口,而是通过 HTTP_HOST(DNS 名称)。
对我来说,site1 = shop.smartgart.com,site2 = one0.com。
我将其放入 site1 的 .htaccess 中:
也就是说:如果正在处理的 HTTP_HOST 不是 site1,则使用提供的后缀 ($1) 重定向到 site1。
对我有用!
I had site1 with https (certificate) and site2 with http (without certificate), both on the same IP (virtual hosts.
Then I noteiced that site2 was getting incorrectly indexed by Google for https, using site1's content.
Whilst for RewriteCond listening
sit in the .htaccess for site2,
sit in the .htaccess for site1.
But then the discrimination no longer goes by port but by HTTP_HOST (the DNS name).
For me, site1 = shop.smartgart.com, site2 = one0.com.
I put this into site1's .htaccess:
That is: If the HTTP_HOST being handled is not site1, then redirect to site1, using the supplied suffix ($1).
Works for me!
我通过多次重定向解决了这个问题,与 @A Kunin 的答案不同。
因为我对两个站点使用不同的证书,如果我只是从
httpS://test1.com
重定向到httpS://test2.com
,它会报告证书错误。我的解决方案是:
httpS://test1.com
-->http://test1.com
-->httpS://test2.com
I solved this issue with MULTIPLE redirects, not the same as @A Kunin 's answer.
Because I use different certificates for both site, and it will report certificate error if I just redirect from
httpS://test1.com
tohttpS://test2.com
.My solution is:
httpS://test1.com
-->http://test1.com
-->httpS://test2.com