title: How to check if file exists in Apache
body: <p>I've set this up successfully in IIS in the past, but i'm not sure how to do it in Apache.  I want to check to see if a file exists, whether it be:</p>
  
  <pre><code>/path/to/file.php
  /path/to/file.cfm
  /path/to/file.html
  /path/to/
  </code></pre>
  
  <p>If the file does <em>not</em> exist, I want to redirect to /404/, where I have a file that does all 404 related handling.</p>
  
  <p>Lastly, when doing this in IIS, it gave me a CGI.QUERY_STRING of something like:</p>
  
  <pre><code>404;http://example.com/prettyurl
  </code></pre>
  
  <p>Can apache do the same?</p>
  
  <p>This is what i've tried to so far, to no success.  (I'm probably way off here...)</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} -f
  RewriteRule (.*)$ /404/ [R,L,NC]
  </code></pre>
  
  <p>Thanks..</p>