How to set robots.txt globally in nginx for all virtual hosts
- by anup
I am trying to set robots.txt for all virtual hosts under nginx http server.
I was able to do it in Apache by putting the following in main httpd.conf:
<Location "/robots.txt">
SetHandler None
</Location>
Alias /robots.txt /var/www/html/robots.txt
I tried doing something similar with nginx by adding the lines given below (a) within nginx.conf and (b) as include conf.d/robots.conf
location ^~ /robots.txt {
alias /var/www/html/robots.txt;
}
I have tried with '=' and even put it in one of the virtual host to test it. Nothing seemed to work.
What am I missing here? Is there another way to achieve this?