Expires headers for url rewrite rules

bogdanb nginx-forum at nginx.us
Mon Oct 21 09:52:57 UTC 2013

In my config I have some url rewrite rules for images as seen below:

location / {
    rewrite ^/custom/path/(.*)/(.*)-(.*).jpg$
/media/images/products/$1/$3.jpg last;

They work just fine. I'm also trying to set Expire headers for all static
resources (images, css, js). I've added the following block for that:

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires 1y;

This works fine for everything except for the images that have the url
rewrite rules (which return 404 Not found). Anyone know what I'm doing wrong


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

More information about the nginx mailing list