title: How to rewrite nginx to execute a php file before serving static content?
body: <p>I am trying to do this in <code>nginx</code> but I just cannot get it to work:</p>
  
  <pre><code># protect images
  RewriteCond %{REQUEST_FILENAME} \.(bmp|gif|ico|jpe|jpeg|jpg|png)$
  RewriteRule .* /path-to-file.php [L,QSA]
  </code></pre>
  
  <p>Tried it with <code>try_files</code> and <code>rewrite</code>, any advice is appreciated!</p>