Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have the following two domains:

domain.com

test.domain.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 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?

Thanks

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.

1 Answer 1

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

 
discard

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.