The company I do SEO for have changed their domain name.
I have written 301 rewrites to redirect traffic to the new domain. So far, I have a rewrite for 3 changes, of which there are many. By the time I have finished doing them all, there will be around 30 rewrites, which seems a bit silly!
Is there a wildcard I can use to just make sure the following 3 arguments are met?
- Must always point to the www. version.
- Must always point to the co.uk version.
- Must ALWAYS change old URL to new.
It would be something like this...
(.*)example-old(.*)
= www.example-new.co.uk
and
(.*)example-old(.*)/(.*)
= www.example-new.co.uk/directory
The below code sorts out problem 3, but it won't solve them all.
If there is a short bit of code I can use, which uses wildcards, this will be perfect.
Any help, much appreciated!
# 301 --- http://example.co.uk => http://www.example-new.co.uk
RewriteCond %{HTTP_HOST} ^example\.co\.uk$
RewriteRule ^$ http://www.example-new.co.uk/? [L,R=301]
# 301 --- http://www.example.co.uk => http://www.example-new.co.uk
RewriteCond %{HTTP_HOST} ^www\.example\.co\.uk$
RewriteRule ^$ http://www.example-new.co.uk/? [L,R=301]
# 301 --- http://example.com => http://www.example-new.co.uk
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^$ http://www.example-new.co.uk/? [L,R=301]
# 301 --- http://www.example.com => http://www.example-new.co.uk
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^$ http://www.example-new.co.uk/? [L,R=301]