Expires headers for url rewrite rules

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
here?

Thanks

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

On Mon, Oct 21, 2013 at 05:52:57AM -0400, bogdanb wrote:

Hi there,

location / {

location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {

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
here?

One request is handled in one location.

Put all of the configuration that you want to apply to a request, within
the one location{} block that handles that request.

f

Francis D. [email protected]

Moving the rewrite rules inside the " ~*
.(js|css|png|jpg|jpeg|gif|ico)$ {
" block did the trick.

Thanks a lot for the quick reply.

Francis D. Wrote:

rewrite rules (which return 404 Not found). Anyone know what I’m

Francis D. [email protected]


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs