Follow us on Twitter

How do I redirect parked domains to the main account domain using mod_rewrite?

Sometimes to protect your brand you will have several domains relating to one site however you may only want your visitors see the main domain in the web browser.

As an example we have ukwebsolutionsdirect.com and ukwebsolutionsdirect.co.uk, our main domain name for our site is ukwebsolutionsdirect.co.uk so anyone visiting ukwebsolutionsdirect.com is redirected to the .co.uk domain.

All you need to do is add a little mod_rewrite code as shown below to your .htaccess file, you will find the .htaccess file in your public_html folder.

There are two examples below, the first being for a .co.uk domain and the second for .com domain name.

###### .CO.UK DOMAIN EXAMPLE ###########

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^exampledomain\.co\.uk$
RewriteRule ^(.*)$ http://exampledomain.co.uk/$1 [R=permanent,L]

 

###### .COM DOMAIN EXAMPLE ############

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^exampledomain\.com$
RewriteRule ^(.*)$ http://exampledomain.com/$1 [R=permanent,L]

NOTE: Don't forget to replace "exampledomain.com" with your actual domain name.


Was this answer helpful?

Related Articles

Mod_rewrite is an Apache web server module installed on all of our web servers by default, all our web hosting accounts support mod_rewrite...
To force all website visitors to use either user the www. part of the domain or not in the URL (useful for search engines) create a file...
Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can redirect your user to maintenance page easily by...
If you want to redirect your visitors to the secure version of your site, you can use the following example in your .htaccess file. It will force...