I understand the regexp. $1 = 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?)