views:

31

answers:

2

I have a website at a.com (for example). I also have a couple of other domain names which I am not using for anything: b.com and c.com. They currently forward to a.com. I have noticed that Google is indexing content from my site using b.com/stuff and c.com/stuff, not just a.com/stuff. What is the proper way to tell Google to only index content via a.com, not b.com and c.com?

It seems as if a 301 redirect via htaccess is the best solution, but I am not sure how to do that. There is only the one htaccess file (each domain does not have its own htaccess file).

b.com and c.com are not meant to be aliases of a.com, they are just other domain names I am reserving for possible future projects.

+1  A: 

robots.txt is the way to tell spiders what to crawl and what to not crawl. If you put the following in the root of your site at /robots.txt:

User-agent: *
Disallow: /

A well-behaved spider will not search any part of your site. Most large sites have a robots.txt, like google

User-agent: *
Disallow: /search
Disallow: /groups
Disallow: /images
Disallow: /news
#and so on ...
Paul Rubel
That doesn't work if all the domains point to the same website. The robots.txt will be the same for `a.com` as it is for `b.com`. So he will deny all robots access to not only `b.com` and `c.com`. But also `a.com`.
WoLpH
Thanks, but there is no way to put anything at b.com - it is simply a domain name which I have reserved which forwards to a.com.
shipshape
@WoLpH, you could produce the robots.txt file with PHP, ASP.NET, etc. where it two domains on the same website, though in this case shipshape's best bet is probably to 301 as per the other answer.
Jon Hanna
@Jon Hanna: true, in that case it would work.
WoLpH
At this point I'll leave it up just for the comments. @Jon Hanna, good points.
Paul Rubel
It's well worth leaving up. While the other answer suits the querant better for reasons they detailed later, this could totally be someone's life-saving google answer :)
Jon Hanna
+1  A: 

You can simply create a redirect with a .htaccess file like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} \.b\.com$ [OR]
RewriteCond %{HTTP_HOST} \.c\.com$
RewriteRule ^(.*)$ http://a.com/$1 [R=301,L]
WoLpH
Thanks, this worked great. I removed the "\." before b\.com and c\.com, because I am redirecting to www.a.com, and this way it works with both www.b.com and just b.com.
shipshape