Htaccess for addon domains
By Ashley • Apr 13th, 2008 • Category: SEOFor those of you that make use of add-on domains on your hosting accoumt, its important to setup an .htaccess file to redirect any visitors or bots who find their way to one of the subdomains., to aviod duplicate content issues.
There are three (well six actually!) ways of accessing an add-on domain:
Root domain name (ie. www.addondomain.co.uk)
Subdomain (ie. www.addondomain.the-hosting-domain.co.uk)
Subfolder (ie. www.the-hosting-domain.co.uk/addondomain)
Then of course you have the same three again without the www.
So in order to avoid duplicate sites being spidered and indexed, we can use a few command in the .htaccess file so that all possible names resolve at www.addondomain.co.uk.
Here is what you need to put in you htaccess file in the directory that houses your add-on domain ie. www.the-hosting-domain.co.uk/add-on/ :
Code:
Options +FollowSymlinks
RewriteEngine OnRewriteCond %{HTTP_HOST} ^addondomain\.co.uk [NC]
RewriteRule ^(.*) http://www.addondomain.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.addondomain.the-hosting-domain\.co.uk
RewriteRule ^(.*)$ http://www.addondomain.co.uk/$1 [R=permanent,L]
RewriteCond %{HTTP_HOST} ^addondomain.the-hosting-domain\.co.uk
RewriteRule ^(.*)$ http://www.addondomain.co.uk/$1 [R=permanent,L]
And add this to the .htaccess file in the root domain: ie. www.thehostingdomain.co.uk
Code:
Options +FollowSymlinks
RewriteEngine OnRedirect /addondomain http://www.addondomain.co.uk
That should work!
Please note in my example:
addondomain = Rootdomain name
the-hosting-domain = The domain name that hosts your add-on domain.
Feel free to ask any questions.
[...] Re: Addon domains - ok for seo? There can be problems with duplicate content if you dont set it up right. More info here: Rankwell ? Blog Archive ? Htaccess for addon domains [...]
So would you have to use robots.txt from the main url to block googlebot from searching the directory or wld you actually allow googlebot to go there and then the hataccess will redirect googlebot?
Hi Mark
No need for a robots.txt entry (infact it could be detimental to you), if you’ve setup the redirect correctly Google visits the old URL gets told its been moved / changed and thats job done.
Hi,
With so many different voices on the Internet, I’ve been baffled by the same duplicate content issue. Out of concerns over the duplicate issue, we create a robot.txt at the root of our primary domain to disallow the crawling of the subdirectory where the addon resides. Then we use another robot.txt at the addon root to allow search engine crawling.
Advice will be greatly appreciated.
Whilst a robots.txt exclusion on the main (hosting) domain will stop Google (and other search engine bots) visiting your pages, there is nothing to stop normal users visiting and linking to the pages, therefore implementing 301 redirects within htaccess files really is the best option.