Forum Moderators: goodroi

Message Too Old, No Replies

1 robots.txt across multiple domains, pt. 2

Continuation of 1 robots.txt file across multiple domains

         

EvanDonovan

4:42 pm on Jul 22, 2009 (gmt 0)

10+ Year Member



I tried to reply to deadsetchamp's thread about using 1 robots.txt file across multiple domains, but I was not able to do so since the thread was considered to be too old.

It took me about 1/2 hour of digging on the web to find out how to do this properly in Apache .htaccess (with mod_rewrite enabled), so I decided it would be helpful if I just posted the code that I finally got worked:


RewriteCond %{HTTP_HOST} ^.*myspanishsite\.com [NC]
RewriteRule ^robots.txt$ /robots-es.txt [L,NC]

The main point on which I was getting stuck was that I was putting the full URL in the RewriteRule. Then, I discovered you can't do that or else it will be a 301 redirect instead of a silent redirect.

g1smd

8:15 pm on Jul 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes. You got it (many don't).

If target is a file then you have a rewrite.

If target is a URL then you have a redirect.

That's it!