robots.txt rewrite for many second-level domains

Martin Minka martin.minka at
Sun Jan 6 23:34:28 MSK 2008

how to use "rewrite" and "set" in nginx to use different robots.txt for 
different second-level domains.

My idea:
if ($server_name ~* XXX) {
    set secondlevel $2
rewrite ^/robots.txt$ /robots-$secondlevel.txt last;

Am I on the right way ? Could somebody help me with the regular 
expresion XXX ?
Or is there another way ?

More information about the nginx mailing list