Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

apache - old https causing issues in htaccess redirect

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

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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).

Other similar answers:

How to redirect HTTPS requests to HTTP without a certificate (Apache VirtualHosts)

How to redirect https to http without any SSL Certificate

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...