Using the http://wiki.nginx.org/NginxHttpCoreModule#alias example regarding how to use sub directory aliases, I've noticed it does not mention how to do it dynamically.
In the following example...
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.
If I'm creating a folder labeled the username that the user created once signing up, then this folder name would always be unique and different. How do I alter the regex in the example above so that the word download also becomes a wild card sub directory?
location ~ ^/randomusername/(.*)$ {
alias /home/website/profiles/randomusername/$1;
}
You need a little background about regex.
Please try the code below and see if it helps.
Well, after learning NGINX here is the answer I was looking for 9 years ago.
@Kristi Jorjii: Below, we use the /[^/]*$/ regex to match the part of the URL after the last slash.