title: nginx rewrite rule conflict
body: <p>I am having a conflict with two blocks with nginx 1.8.0.</p>
  
  <p>The first block is to setup static cache for certain file types:</p>
  
  <pre><code>location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ {
    add_header "Access-Control-Allow-Origin" "*";
    access_log off;
    log_not_found off;
    expires max;
  }
  </code></pre>
  
  <p>The second block is a series of rewrites defined by filetype:</p>
  
  <pre><code>location /files {
  rewrite ^/files/master\.([0-9]+)?\.css$ /min/?g=css&amp;456 break;
  rewrite ^/files/master\.([0-9]+)?\.js$ /min/?g=js&amp;456 break;
  rewrite ^/files/second\.([0-9]+)?\.js$ /min/?g=jsa&amp;456 break;
  }
  </code></pre>
  
  <p>The rewrites result in a 404. Any rewrite that uses a filetype defined in the static cache rule results in a 404 error. If I change the rewrite rule to a different filetype or comment out the static cache file block, it works.</p>
  
  <p>What am I missing in the cache static files that is preventing a rewrite from being performed at a later config setting?</p>