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.

  • 148 Users Found This Useful
Was this answer helpful?

Related Articles

Redirect to maintenance page during upgrade using .htaccess

Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can...

How do I force my website to use/not use the "www" prefix?

To force all website visitors to use either user the www. part of the domain or not in the URL...

Can I use mod_rewrite?

Mod_rewrite is an Apache web server module installed on all of our web servers by default, all...

How do I force a redirect from http to https?

If you want to redirect your visitors to the secure version of your site, you can use the...

Redirect to maintenance page during upgrade using .htaccess

Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can...