mod_rewrite condition not firing?
Before I redirect the user, I want to check if the redirected-to-file actually exists. Now the following code works yet right when I add the bit which is currently commented out it skips the rewrite rule altogether.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# RewriteCond cache/$1.html -f
RewriteRule ^([^/]+)/?([^/]*) cache/$1.html [L]
<IfModule>
Ive been struggl开发者_开发技巧ing on this for three days now, any help would be greatly appreciated!!!
In # RewriteCond cache/$1.html -f
the $1
doesn't refer to anything, so it is going to skip your RewriteRule.
Try
RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_URI}.html -s
RewriteCond Documentation
My first impression is to check that cache/$1.html exists and that you aren't accidentally redirecting from myserver.com/index.html -> to -> myserver.com/cache/index.html.html
精彩评论