Using .htaccess to redirect a .co.uk domain to .com for all pages

Customers often register .co.uk , .com  and .uk  domains to protect their brand. Domains can be left dormant or configured to redirect to the active site. A redirect is useful if visitors try to guess your top level domain in the browser address bar.

To be safe the best policy is to implement 301 redirects to the main domain. If domains are serving duplicate content you run the risk of being penalised.

You can use the following rewrite rule under the assumption that domains haven’t been used previously. If you are dealing with multiple domains with active sites it’s probably best to sit down and map out redirects to relevant landing pages. I’m not an expert in this area, please do plenty of research first.

This will redirect both www and non-www traffic for yourdomain.co.uk to www.yourdomain.com

RewriteEngine On
RewriteBase /

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

 

 

 

 

You May Also Like