开发者

Strange behavior RewriteCond on Apache 2.2

开发者 https://www.devze.com 2023-01-18 06:13 出处:网络
working .htaccess config: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

working .htaccess config:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} ^thumbs/(.*)$
RewriteRule ^(.+)$ /index.php [L,QSA]

All 404 queries to /thumbs/ folder not must be catched by /index.php script. Why top .htaccess config work and bottom config not work?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/thumbs/(.*)$
RewriteRule ^(.+)$ /index.php开发者_C百科 [L,QSA]

Apache 2.2.9, Debian


REQUEST_URI contains the requested URI path and does always start with a slash.

So the pattern ^thumbs/(.*)$ does never match as it’s missing the leading /. But the other condition, !^/thumbs/(.*)$, should match every request that’s URI path does not start with /thumbs/.


I think it's because the first slash in

RewriteCond %{REQUEST_URI} !^/thumbs/(.*)$
0

精彩评论

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