I redeveloped my company's website and I'm having some issues with redirecting / SSL
Typing or clicking on http://olddomain.org redirects just fine to https://newdomain.com. However, typing or clicking on the link https://olddomain.org does not redirect to https://newdomain.com and I get this error:
Firefox does not trust this site because it uses a certificate that is not valid for olddomain.org. The certificate is only valid for the following names: *.newdomain.com, newdomain.com
Is there some rewrite conditions I can put in my .htaccess file to fix this? Or is this an issue with the way that I set up the SSL certificate for the new domain?
Here's what I've tried so far:
<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 / http://newdomain.com/
</IfModule>
<br />
and
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?http://olddomain\.org$
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,QSA,L]
CodePudding user response:
Or is this an issue with the way that I set up the SSL certificate for the new domain?
Yes, you need a valid SSL cert that covers the old domain (as indicated in the browser error... "it uses a certificate that is not valid for olddomain.org").
Without the valid cert the browser cannot connect (securely) to olddomain.org
so never even sees the redirect directives.
CodePudding user response:
I recommend having CloudFlare redirect your old domain to your new domain. They do a great job of redirecting entire domains using their free service tier. They even create and manage the security certificate for you so that HTTPS redirects work.
It is a little bit of work to set up. You have to set the NS records for the domain name to point to cloudflare and tweak several settings within the Cloudflare site. I have complete instructions on Webmasters Stack Exchange that you can follow.