Reputation: 2765
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.
Upvotes: 3
Views: 1105
Reputation: 2765
I ended up with this which seems to work:
location = /robots.txt {
expires 30d;
add_header Cache-Control public;
try_files /robots.txt @shared;
}
location @shared {
root /var/www/shared;
}
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!
Upvotes: 4