there is another one, but more specific, but it comes before location ~ ^/images/: location ~ "^(/images/)(\d{1})/(\d{2})/(.*\.jpg$)" { } Posted at Nginx Forum: http://forum.nginx.org/read.php?2,240201,240205#msg-240205