Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to redirect https to new domain?

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]
like image 679
sarahm16 Avatar asked Apr 26 '26 19:04

sarahm16


1 Answers

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.

like image 78
MrWhite Avatar answered Apr 28 '26 10:04

MrWhite