Skip to content

Instantly share code, notes, and snippets.

@cr0t
Created November 15, 2010 19:52
Show Gist options
  • Save cr0t/700847 to your computer and use it in GitHub Desktop.
Save cr0t/700847 to your computer and use it in GitHub Desktop.
Nginx location rewrite rules for some special sort of images. For example, we need to send /var/www/domain/object-images/997/100x74/9979998.jpg file for the query URI like: http://example.com/object-images/997/100x74/9979998/MacBook-Pro-13-inches.jpg
location ~ ^.+\.(jpe?g|gif|png)$ {
rewrite ^(/object-images)/(\d+)/([0-9x]+)/(\d+)/([a-zA-Z0-9-]+).jpg$ $1/$2/$3/$4.jpg last;
try_files $uri /images/empty.png;
access_log off;
expires 3h;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment