开发者

How do I interpolate values in the TestString portion of an .htaccess RewriteCond?

开发者 https://www.devze.com 2023-01-03 15:38 出处:网络
How do I interpolate values like %{REQUEST_FILENAME} in the TestString part of a RewriteCond directive? Here\'s what I\'m trying to do:

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?


# 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]


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号