Forum Moderators: phranque
I need to redirect
www.mydomain.com
mydomain.com
mydomain.co.uk
to www.mydomain.co.uk
The redirects need to be permanent redirects which will not confuse the search engine spiders.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)mydomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^mydomain\.co.uk$ [NC]
RewriteRule ^.*$ http://www.mydomain.co.uk%{REQUEST_URI} [R=301,L]
At the moment www.mydomain.co.uk doesn't redirect to www.mydomain.co.uk/ (i.e. with the forward slash)
Am i right in thinking that this is not a good idea because it will create a loop?
You should not have any problem with looping - It only redirects if there is HTTP_HOST information (HTTP 1.0 clients do not send HOST headers) AND the HTTP_HOST is not already www.yoursite.co.uk, so the ruleset will break itself out of a loop.
Justin