301 Direct to new Domain on https:// not https://www

20 Views Asked by At

I am looking to 301 an entire domain on https://www.olddomain.co.uk to a new domain on https://newdomain.com via .htaccess. Currently, the version I have will only work if you manually remove the www from the old link showing in Google SERP for the old domain listing - so it shows 'This site can’t be reached' when clicked. Removing the 'www' part of the URL and hitting return performs the redirect.

Current .htacess is:-

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
</IfModule>

And I've also tried:-

RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.co.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.co.uk [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]

Important to keep the SEO value form the old domain. Any assistance appreciated here.

Thanks in advance

Glennboy

1

There are 1 best solutions below

0
glennyboy On

Fixed in 2 parts:-

  1. The DNS settings on the domain did not cover 'www' which was a simple error that would have stopped 'www' showing anyway.
  2. Added a valid SSL Certificate to the old domain to ensure safe traversing of SSL - SSL

In short, the issue was not the .htaccess implementation which was perfectly valid and now working fine.