Hello,
Me and a friend of mine has been hasseling the mod_rewrite module of Apache and we won't get the result we want.
We're trying to redirect '404's to a URL catcher script which will do some DB queries, and if that URL does not exist, show the real 404-document.
That is, we want Apache to show us the real files, the real directories, the real index-files if they exist, just like normally. But, if that resource is not found, we want mod_rewrite to redirect the use to the URL-catcher script (built in PHP ofcourse!).
We've come this far:
RewriteEngine On
RewriteCond %{IS_SUBREQ} true
RewriteCond %{REQUEST_URI} !-U
RewriteRule (.*) /doesntexist [G]
RewriteCond %{REQUEST_URI} .*.[a-z0-9]+
RewriteCond %{REQUEST_URI} !-U
RewriteRule .* /path/to/file.php [NS]
However, in the second pass it won't work. :-(
It's no problem to do this without directory listings and/or index-files (such as index.html)
But, when we want to combine all it just won't give us what we want. We suspect that on the second pass "!-U" won't do what it should do...
Any help is greatly appreciated!
Cheers!
/Jocke