I would like to have a default robots.txt file served from a shared place (absolute path), if there’s no relative one.
I tried this without luck:
location = /robots.txt {
expires 30d;
add_header Cache-Control public;
try_files /robots.txt /var/www/shared/robots.txt =404;
}
But it just returns 404.
I ended up with this which seems to work:
I must admit though, that I liked “try_files” better, but it just doesn’t seem to work with absolute paths.
If anyone has a better/other solution, I would love to see!