0

So, my client changed their old domain to a new domain which had an SSL cert on it. The old domain is indexed as https://olddomain.com and even though I changed the forwarding in Godaddy to go to the new domain it will not load! I'm trying to redirect with a htaccess file but I have not had any success. So, https://olddomain.com does not redirect but if you type in olddomain.com it redirects.

Can anyone tell me what I need to do to get the https://olddomain.com to redirect? FYI: I do not have hosting setup for the old domain.

My htaccess file is just this:

 RewriteEngine On 
 RewriteCond %{SERVER_PORT} 80 
 RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R,L]

 RewriteCond %{HTTPS_HOST} \olddomain.com$
 RewriteRule ^(.*)$  https://www.newdomain.com$1 [R=301,L]
Dede
  • 55
  • 1
  • 2
  • 8

2 Answers2

0

Your 2 rules can be combined into one and \olddomain.com$ is incorrect regex because of \o

Try this rule:

 RewriteEngine On 

 RewriteCond %{HTTP_HOST} olddomain\.com$ [NC,OR]
 RewriteCond %{HTTPS} off
 RewriteRule ^ https://www.newdomain.com%{REQUEST_URI} [L,NE,R=301]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thank you both but the old https:// olddaomin.com is still not redirecting. It's just getting "This webpage is not available." – Dede Nov 19 '13 at 17:41
  • Is `olddaomin.com` still a valid address? Can you ping it? I also corrected my typo so try edited answer. – anubhava Nov 19 '13 at 17:48
0

There is no such thing as HTTPS_HOST, see RewriteCond for a list of available variables.

You have HTTP_HOST or HTTPS available. If you want to redirect to https://newdomain.com, you can just check for olddomain.com

RewriteCond %{HTTP_HOST} olddomain.com$
RewriteRule ^(.*)$  https://www.newdomain.com/$1 [R,L]

Don't forget the slash, because in a .htaccess context, the leading slash is removed. Otherwise, http://olddomain.com/page.html would be redirected to https://www.newdomain.compage.html. Not exactky what you would expect.

Never test with 301 enabled, see this answer Tips for debugging .htaccess rewrite rules for details.

Community
  • 1
  • 1
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198