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