Mobile app version of vmapp.org
Login or Join
Fox8124981

: Preventing Spiders on One Subdomain? We currently host multiple sites on the same domain that all live in the same physical directory on the server. Each is database driven and lives at a unique

@Fox8124981

Posted in: #GoogleSearch #RobotsTxt #Subdomain

We currently host multiple sites on the same domain that all live in the same physical directory on the server. Each is database driven and lives at a unique subdomain. For example, site1.example.com, site2.example.com, etc. However, because all of these sites live in the same directory, they share a robots.txt file.

I would like to set up a test/demo site on this same codebase(i.e. demo.example.com), but I do not want it to be indexed by search engines. Is there any way that I can configure robots.txt to disallow an entire subdomain while not affecting other subdomains that live in the same physical location?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Fox8124981

3 Comments

Sorted by latest first Latest Oldest Best

 

@Fox8124981

I ended up using mod_rewrite to accomplish what I need:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^demo.example.com
RewriteRule ^robots.txt$ robots-demo.txt

RewriteCond %{HTTP_HOST} !^demo.example.com
RewriteRule ^robots.txt$ robots-othersites.txt

10% popularity Vote Up Vote Down


 

@Angie530

You can configure the subdomain site to send an additional X-Robots-tag HTTP header, assuming that each subdomain is set up as it's own virtual site.

That will allow you to tell spiders not to index that subdomain. The catch is that I do not know how many crawlers currently support this header. A quick look indicates that Google and Yahoo! do.

10% popularity Vote Up Vote Down


 

@LarsenBagley505

You can use a meta robots tag, which is supported by all of the major search engines today:



<meta name="robots" content="noindex" />


I'm not exactly sure how to do this with robots.txt, though.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme