旧 https 导致 htaccess 重定向问题 [英] old https causing issues in htaccess redirect

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

问题描述

我正在将旧站点 URL 重定向到新站点.

I am redirecting my old site URL to a new site.

我创建了一个 htaccess,它将所有旧链接(root 除外)重定向到添加了/shop/目录的新路径.一切正常,但旧的 https 是所有流量的去向,它抛出证书错误,因为新服务器帐户上没有 SSL.

I have created a htaccess that redirects all old links (except root) to new path with added /shop/ directory. It all works fine but the old https is what all traffic is going to and it is throwing a certificate error becuase there is not SSL on the new server account.

这是当前的 htaccess.

Here is the current htaccess.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteRule (.*)$ https://www.newsite.com/ [R=301,NC]

RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteRule ^(.*).(php|html)$ https://www.newsite.com/shop/$1.$2 [L,R=301,NC]

任何建议将不胜感激,在此先感谢您!

Any advice would be greatly appreciated, thank you in advance!

~M

推荐答案

使用 .htaccess 无法解决您的问题.如果您没有可用的 https 站点,则不能使用 HTTP 重写从 HTTPS 重定向到任何地方,因为客户端和服务器甚至需要 SSL 证书才能开始使用 HTTPS 相互通信.您应该为 oldsite.com 创建另一个虚拟主机来执行重定向(这些天您应该能够获得非常便宜甚至免费的 SSL 证书).

There is no way to solve your problem using .htaccess. You can not use HTTP rewrite to redirect from HTTPS to anywhere if you don't have working https site, since SSL certificate is needed for client and server to even begin to talk to each other using HTTPS. You should create another virtual host for oldsite.com that will do the redirect (you should be able to get very cheap or even free SSL cert these days).

其他类似答案:

如何重定向 HTTPS 请求到没有证书的 HTTP (Apache VirtualHosts)

如何在没有任何 SSL 的情况下将 https 重定向到 http证书

https://serverfault.com/questions/429274/how-to-redirect-from-https-to-http-before-server-error

这篇关于旧 https 导致 htaccess 重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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