Reputation: 585
I need to redirect a list of predefined subdomains to my websites root.
I am struggling with the wildcards, can anyone help?
# Redirect all old subdomains
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(random|sub|domains)\.example\.co\.uk [NC]
RewriteRule ^/(.*) http://www.example.co.uk/$1 [L, R=301]
</IfModule>
It needs to be predefined and done via .htaccess as it's Google that is picking up and hitting 404's.
Any help would be greatly appreciated.
Thanks
Upvotes: 1
Views: 138
Reputation: 9529
If this in your .htaccess then your RewriteRule will never match if you have a leading slash. Remove it and it should work i.e
RewriteRule ^(.*) http://www.example.co.uk/$1 [L,R=301]
Upvotes: 1