I have a file caching system for a php application. if a file needs cached i save it to a cache dir as flat html mimicking the directory structure of the request_uri
how could i check with htaccess if there is a flat file in this cache dir before continuing as normal? currently i check with php, but ideally if there is a cached file, i would like to have no serverside code run on that request.
my current setup routes everything through the index file and then php determines what files to include based on the uri.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
so say that a request came in as
http://localhost/posts/45/the-name-of-my-post/
or
http://localhost/posts/45/the-name-of-my-post
how would i check to see if there is a flat html file located in
app/tmp/cache/posts/45/the-name-of-my-post/index.html
thanks and sorry if this is a stupid question, im fairly novice with rewrite rules. If anyone has a better idea how to elimimate php code from a cached request, im open to anything.
ok now trying
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ^app/tmp/cache/%{REQUEST_URI} -d
RewriteRule (.*) ^app/tmp/cache/%{REQUEST_URI}
# map everything to the index file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond ^app/tmp/cache/%{REQUEST_URI} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
tried this but doenst seem to be working, what am i overlooking?
my request is
http://localhost/posts/view/23/another-post/
trying to serve up
http://localhost/app/tmp/cache/posts/view/23/another-post/