How to redirect Addon Domain -htaccess changes

SEO, Tips N Tricks 20 September 20095 Comments

I recently added techofweb.com as an Add-on Domain to mine primary domain oceanofweb.com

Addon Domains can be accessed in following 3 different ways:
*www.addonDomain.com
*www.primaryDomain.com/addonDomain.com
*www.addonDomain.primaryDomain.com

You can have the same thing in following ways too:
*Without www
*With prefixing http://
*With prefixing http:// and removing www

So, it counts total of 12 different ways your add-on domain can be accessed through browser, resulting in the addition of great duplicacy for Google.

I was also facing the same problem and it ate my whole 1 day in order for the solution to come up. I mailed to my many blogging friends, contacted Hostgator customer support, googled but nowhere solution was coming. While googling, I got the following code at many places:

Options +FollowSymlinks
RewriteEngine OnRewriteCond %{HTTP_HOST} ^addondomain.com [NC]
RewriteRule ^(.*) http://www.addondomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.addondomain.primarydomain.com
RewriteRule ^(.*)$ http://www.addondomain.com/$1 [R=permanent,L]
RewriteCond %{HTTP_HOST} ^addondomain.primarydomain.com
RewriteRule ^(.*)$ http://www.addondomain.com/$1 [R=permanent,L]

To place this code, go to your FTP/cpanel, primarydomain directory>>>addondomain directory>>> open .htaccess
And copy the above code in it.
But unfortunately, this code too didn’t work for me. ;)

So, if you too on the same floor, then try this:
Open your .htaccess file and paste the below code under mod_rewrite in it (by replacing addondomain with your domain).

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} !^(www.)?addondomain.com$ [NC]
RewriteCond %{HTTP_HOST} !^$ [NC]
RewriteRule ^(.*)$ http://www.addondomain.com/$1 [R=301,NC,L]

This code worked for me like a charm :-)
So, try the above 2 codes. Atleast one will definitely work for you.
Now, access your site by the above 12 different ways.
Every time, you would be redirected to http://addondomain.com

NOTE: Please do back up your .htaccess before making any changes
Replace addondomain with your respective addondomain

Related Posts with Thumbnails

Bookmark It!!!

Buzz It   Twitt It   StumbleUpon It   Facebook It   Digg It   Delicious It   Reditt It   Reditt It  

Author

Atul

Atul - who has written 100 posts on Tech Of Web.

Atul is a professional blogger and techie who writes at TechOfWeb.

Subscribe to TechOfWeb feed via RSS || EMAIL || Twitter || Facebook to get instant latest tech updates.

Contact the author

Your Comments

5 Comments so far

  1. Nihar says:

    Great tip atul.

    Thanks.

  2. Chetan Gole says:

    Nice trick buddy, working with .htaccess file is very risky and should be done very carefully.

  3. Polprav says:

    Hello from Russia!
    Can I quote a post in your blog with the link to you?

  4. Atul says:

    @Nihar,@Chetan,@Polprav: Thanks
    @Polprav: yes you can. If any help you can mail me.

  5. shameer says:

    thank you for great information


Share your view

Post a comment

  •  
  • Hostgator Web Hosting Elegant Themes Thesis Theme Woo Premium Themes

    © 2010 Tech Of Web. Powered by Wordpress.

    Wordpress themes by Woo Themes