Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following two domains:



Both point to same folder which is "public_html". What I want is a different robots.txt file for each domain. So when someone browse domain.com/robots.txt then a different file is shown. And when someone go to test.domain.com/robots.txt then a different file is shown. How can I do this using URL rewriting in .htacces?


share|improve this question

migrated from stackoverflow.com Mar 15 '11 at 10:27

This question came from our site for professional and enthusiast programmers.

up vote 6 down vote accepted

Remeber that no one from internet can see your directory tree, so stackoverflow.com/ and test.stackoverflow.com are completely diffrent sites for us and search robots. You can do that by checing http host in query.

RewriteCond %{HTTP_HOST} ^test
RewriteRule robots.txt someotherrobots.txt
share|improve this answer
Thanks man. It works! – Ali Mar 18 '11 at 5:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.