title: Rewrite for all images AND one particular php filename
body: <p>As a precaution against hotlinking, I've been using the following rule to redirect people with the wrong referrer to our logo instead of the actual image:</p>
  
  <pre><code>    #Naughty hotlinkers
      RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$ [NC]
      RewriteCond %{HTTP_REFERER} !^$
      RewriteCond %{HTTP_REFERER} !sitedomain\.com [NC]
      RewriteCond %{HTTP_REFERER} !google\. [NC]
      RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
      RewriteRule (.*) assets/hotlinked/logo.jpg [L]
  </code></pre>
  
  <p>It works well, for images.</p>
  
  <p>I'm in the process of writing horrible wrapping code to preserve images embedded in our user's content with their src pointing to a php file that was used to filter requests for and serve our images. Although new images will no longer be served this way, we do need to ensure previously uploaded images are still available from their old address.</p>
  
  <p>Though the images still need to be accessible, this file needs to be guarded against hotlinking as well.</p>
  
  <p>I tried this:</p>
  
  <pre><code>    #Naughty hotlinkers
      RewriteCond %{REQUEST_FILENAME} .*jpg$|.*gif$|.*png$|.*gp2\.php.* [NC]
      RewriteCond %{HTTP_REFERER} !^$
      RewriteCond %{HTTP_REFERER} !sitedomain\.com [NC]
      RewriteCond %{HTTP_REFERER} !google\. [NC]
      RewriteCond %{HTTP_REFERER} !search\?q=cache [NC]
      RewriteRule (.*) assets/hotlinked/logo.jpg [L]
  </code></pre>
  
  <p>But no dice.</p>
  
  <p>The file I want to protect used in image's src like:</p>
  
  <pre><code>    http://sitedomain/legacy/gp2.php?p=long_stupid_string
  </code></pre>
  
  <p>Please will an apache guru tell me what stupid thing I'm doing wrong here?</p>
  
  <p>Edit:</p>
  
  <p>I'm testing hotlink prevention here:</p>
  
  <p>(image) <a href="http://pagesofinterest.net/hotlinktest.html" rel="nofollow noreferrer">here</a></p>
  
  <p>(php) <a href="http://pagesofinterest.net/ecpod_referrer.html" rel="nofollow noreferrer">and here</a></p>