I am currently moving a domain from one to the other, this is not an HTTPS move but rather a move from exampleone.co.uk
to exampletwo.co.uk
. I am using this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampleone\.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.exampleone\.co.uk$
RewriteRule (.*)$ http://www.exampletwo.co.uk/$1 [R=301,L]
</IfModule>
This works well for existing page names as the site structure isn't changing. However it also returns non existing pages to the index page basically creating a soft 404 which is not desirable.
Does anybody have any idea how to redirect valid pages from exampleone.co.uk
via 301 but returning a 404 when the page doesn't exist but also taking into account valid 301's within the new domain.
So we want it to:
- Redirect via 301 old site to new
- Honour valid 301's within the new site (future proofing)
- Return 404 instead of redirecting to index page when 301 does not exist
http://www.exampletwo.co.uk/this-page-does-not-exist
does not return a 404? That would be something you need to fix on the new site. Do these two domains point to the same filesystem?