1

I have the following two domains:

example.com

test.example.com

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 example.com/robots.txt then a different file is shown. And when someone go to test.example.com/robots.txt then a different file is shown.

How can I do this using URL rewriting in .htaccess?

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

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

6

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 checking the HTTP host in query:

RewriteCond %{HTTP_HOST} ^test
RewriteRule robots.txt someotherrobots.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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