Score:0

nginx configuration for robots.txt

cn flag

I've read other answers and Nginx docs, and I can't figure out why this works:

location = /robots.txt {
    alias /<fullpath>/static/robots.allow.txt;
}

and this don't:

location = /robots.txt {
    rewrite .* /robots.allow.txt last;
}

for the second one, server root is root /<fullpath>/static;

Richard Smith avatar
jp flag
The `rewrite...last` will search for a new location to process the rewritten URI. If you use `rewrite...break` the rewritten URI is processed within the same location.
Nestor avatar
cn flag
You're right, it worked, thanks! Though I have another question, when the request is processed a new file `robots.txt` is created in the very same location, why does that happen?
Richard Smith avatar
jp flag
I have never seen that. What does the file contain?
Nestor avatar
cn flag
The very same content
djdomi avatar
za flag
@richard some CMS have custom instead standard path used thats like you would use htaccess to fix this url ;)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.