0
votes

I'm attempting to change the .htaccess on a website such that each page redirects to a specific page on another website. I've managed to get the non-root level pages to redirect to the new domain with no problem, but however I seem to try to redirect from the root of the old website I end up getting a 'too many redirects' problem. This feels pretty key for optimizing someone's site when they've changed from a previous domain, so would be useful to know.

The code I've got working is this:

Redirect 301 /my_counselling.html newsite.org.uk/
Redirect 301 /fees_and_contacts.html newsite.org.uk//?page_id=11
Redirect 301 /qualifications.html newsite.org.uk/
Redirect 301 /resources.html newsite.org.uk/
Redirect 301 /abuse.html newsite.org.uk/
Redirect 301 /drug_and_alchol.html newsite.org.uk//?page_id=57
Redirect 301 /lgbt_sexuality.html newsite.org.uk//?page_id=13
Redirect 301 /dyslexia.html newsite.org.uk//?page_id=8

But the following attempts to match the ROOT level all fail:

Redirect 301 / newsite.org.uk/

or

RewriteRule oldsite.com/ newsite.org.uk [R=301,L,NC]

or

RedirectMatch 301 ^/ newsite.org.uk/

which are suggestions I've read.

This feels like it should be very simple. If I can just get visitors and bots that would have gone to the old site's root to now go to the new site's root I'll be done.

Thanks so much!

1

1 Answers

0
votes

It looks like both domains are on the same server, in that case, You'll need to match against the olddomain using a RewriteCondition and then redirect to the newdomain if that condtion is true.

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