Confused by documentation for /alias/

graq nginx-forum at nginx.us
Wed Aug 10 10:43:00 UTC 2011


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?)

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,213617,213622#msg-213622



More information about the nginx mailing list