title: Expires headers for url rewrite rules in nginx
body: <p>In my nginx config I have some url rewrite rules for images as seen below:</p>
  
  <pre><code>location / {
      rewrite ^/custom/path/(.*)/(.*)-(.*).jpg$ /media/images/products/$1/$3.jpg last;
  }
  </code></pre>
  
  <p>They work just fine. I'm also trying to set <code>Expire</code> headers for all static resources (images, css, js). I've added the following block for that:</p>
  
  <pre><code>location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
      expires 1y;
  }
  </code></pre>
  
  <p>This works fine for everything except the images that have the url rewrite rules (which return <code>404 Not found</code>). Anyone know what I'm doing wrong here?</p>