I'm doing a rewrite with mod_rewrite on every request that does not match an existing file or directory. This is my configuration:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [NC,L]
This is used to map URLs like /abc/foo
or /abc/foo/10
to my app. And it works just fine.
To improve the performance, my app now stores the results of a call to /abc/foo
in a file foo
in the corresponding directory /abc
- so that after the first call the rewrite conditions do no longer apply (file does not exist) and apache directly serves the data without first invoking the app. Works fine as well.
The problem is: Requesting /abc/foo/10
does now no longer cause the URL to get rewritten, instead I get an error "404 File Not Found". The log entries state that the rewrite condition !-f
is no longer true, but actually the file /abc/foo/10
does not exist. /abc/foo
exists, but is a file, not a directory.
How can I get this to work?
(MultiViews is disabled)