location ~ ^/download/(.*)$ {
alias /home/website/files/$1;
}
The request “/download/book.pdf” will return the file
“/home/website/files/book.pdf”. Note again that only part of the request
URI after the location is appended to the path defined by alias. END
Why doesn’t this return the directory “home/website/files/book.pdf/” ?
So for the specific request in the example, we could write:
location ~ ^/download/(.*)$ {
alias /home/website/files/book.pdf;
}
Is it that the example is unrealistic? Because this config does exactly
the same thing:
location /download/ {
alias /home/website/files/;
}
I’m struggling to see the difference, and why one would use the regexp.
How about requesting “/download/baz/foo/book.pdf” for the above regexp
config and this one:
location ~ ^/download/(.*)/foo/ {
alias /home/website/files/$1;
}
(why would I do this?)
Posted at Nginx Forum:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.