ReWrite Rule

Jul 5, 2007 at 7:23 AM
Hi,

I have a single website (single directory) with multiple domains e.g www.sample.com, user1.sample.com, etc. What I would be like to do is to have multiple robots.txt files for each domain? How do I go about doing so?
Jul 5, 2007 at 10:19 PM
This is my first attempt and it doesn't seem to work. Can anyone help?

RewriteCond %{REMOTE_ADDR} ^(127.0.0.1)
RewriteRule (^/robots.txt)(.*\/$)$ /test.txt R,I
Jul 5, 2007 at 10:43 PM
This is my updated code however it only works if I type in localhost/robots.txt. If I were to type in localhost/dir1/robots,txt or localhost/dir/dir2/robots.txt it fails to work. How can I get it work regardless of the number of sub directories?

RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule (^/robots.txt)$ /test.txt R,I
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (^/test.txt)$ /robots.txt I,L
Coordinator
Jul 13, 2007 at 5:39 PM
check the docs on Regular Expressions, and also check the examples and tests.
you should be able to figure this out.