I want a file to be sent to /robots.txt, which I will indicate using a relative path on the server. Wrote the following rule:
location /robots.txt { alias /home/folder1/folder2/folder3/robots.txt; } It does not work, because it puts a slash at the end and goes to site.ru/robots.txt/
How to make so that a slash was not substituted in robots? For all other paths, slash is needed.
UPD I don't know what to think anymore. This construction works as it should:
location /robotz.txt { alias /home/bla/bla/project/robots.txt; } But this adds a slash and gives 404 error:
location /robots.txt { alias /home/bla/bla/project/robots.txt; }
location ~ ^/(robots\.txt)$ { alias /home/folder1/folder2/folder3/$1; }location ~ ^/(robots\.txt)$ { alias /home/folder1/folder2/folder3/$1; }- andreymal$ grep -r robots /etc/nginx? - aleksandr barakin