title: htaccess - conditional rewrite and expire
body: <p><em>Hey there!</em></p>
  
  <p>I have a folder <code>/static</code> in my Apache 2.x server webroot. If a request matches</p>
  
  <pre><code>/static/&lt;somename like [\S-_]+&gt;.(png|jpg|css|js)/\d{8,15}
  </code></pre>
  
  <p>for example</p>
  
  <pre><code>/static/bg.jpg/1335455634
  </code></pre>
  
  <p>I want two things:</p>
  
  <ul>
  <li>url shall be rewritten to <code>/static/bg.jpg</code> (getting rid of the timestamp)</li>
  <li>it shall become a <a href="http://developer.yahoo.com/performance/rules.html#expires">never-expire</a> ('expires 2030, max-age=290304000, public cache, ...)</li>
  </ul>
  
  <p>If the request does not match, the request and it's headers should be as normal, no rewrite. Ideally, any request outside /static/* should not be affected (though «coincidental trailing timetamps» should be rare...)</p>
  
  <p>I have nothing but trouble with FilesMatch / RewriteCond, so I rather not post my poor attempts... (Rewrite in genereal is enabled on my machine, and I do possess the rights to send cache-related headers)</p>
  
  <p><em><strong>Dankeschön!</em></strong></p>