Hide a path node in nginx

dioo asked:

I have the following url:


where 2015/10/pic.jpgis dynamic: 2015 is the year, 10 is the month number and pic.jpg a file name. Every time an image is sent, the year and month folders are created as the current date.

I would like to remove the node “dr” of the url, like the example below:


I found this question, which is the closest to what I need: https://superuser.com/questions/435916/nginx-rewrite-rule-to-remove-path-node

My answer:

You could just add it to your try_files. This is the simplest and will perform better than a rewrite. For example:

try_files /dr$uri $uri ....the rest of it...

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.