views:

16

answers:

2

How do I interpolate values like %{REQUEST_FILENAME} in the TestString part of a RewriteCond directive? Here's what I'm trying to do:

# non-existent requests to /webroot files get 404'd
RewriteCond site/%{REQUEST_FILENAME} !-f
RewriteRule ^/?webroot site/webroot/404 [L]
# otherwise, let them in!
RewriteRule ^/?webroot/(.*)$ site/webroot/$1 [L]

What I want to happen is requests going to domain.com/webroot/image.jpg be checked to see if site/webroot/image.jpg exists. Is there a way to do that?

A: 
RewriteBase /
RewriteCond /full/path/to/site/$0 -f
RewriteRule .* tese/$0 [QSA]

You may also want to deactive the rule for the "site" directory.

Artefacto
A: 
# non-existent requests to /webroot files get 404'd
RewriteCond site/%{REQUEST_FILENAME} !-f
RewriteRule ^/?webroot site/webroot/404 [L]
# otherwise, let them in!
RewriteCond site/%{REQUEST_FILENAME} -f
RewriteRule ^/?webroot/(.*)$ site/webroot/$1 [L]
no