title: mod_rewrite regex to match only if a certain string does NOT exist
body: <p>Looking through my server logs, I see that a lot of pages on my site are requesting <code>favicon.ico</code>, <code>favicon.jpg</code>, <code>favicon.png</code>, etc in a variety of different directories.</p>
  
  <p>Instead of wading through each page to try to figure out where each incorrect request is coming from, I'm writing some apache redirect rules to change a request for any url containing <code>"favicon"</code> to redirect to <code>/favicon.ico</code></p>
  
  <p>My initial naive attempt was this:</p>
  
  <pre><code>RewriteRule favicon /favicon.ico [R=301,L]
  </code></pre>
  
  <p>But that meant that when you actually requested <code>/favicon.ico</code> it would send you into an infinite redirect loop.</p>
  
  <p>Basically what I think I need is a regex which has this effect:</p>
  
  <pre><code>| Request                | Response     |
  |------------------------|--------------|
  | favicon.png            | /favicon.ico |
  | directory/favicon.png  | /favicon.ico |
  | directory/favicon.ico  | /favicon.ico |
  | favicon.ico            | &lt;no match&gt;   |
  </code></pre>