Forum Moderators: phranque
RewriteCond %{REQUEST_URI}(/index\.php)? !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^(.*) /foo/$1 [L] But then I found that it matches the same if I leave out the ():Because it isn’t only matching ^/images. It’s also matching
RewriteCond %{REQUEST_URI} ^/ads|images|cgi-bin
My question is, why?
should I use (?:index\.php)?I think you should use the [NS] flag, so as to bypass all internal requests for /blahblah/index.php (I assume you do not have it in visible URLs).
but I have those 2 conditions before just about every RewriteRuleFrankly that sounds wildly inefficient, since it means the server has to go looking for files and directories over and over and over again. I don't know how big your site is, but is listing everything by name in the body of the rule an option? In particular, anything involving a rewrite to
RewriteCond %{REQUEST_URI} ^/ads|images|cgi-bin
My question is, why? I thought that "/ads" would be seen as the first string, then "images" (without the /) would be the second, so "images" would have never matched... but it does.
RewriteCond %{REQUEST_URI}(/index\.php)? !-f
RewriteCond %{REQUEST_URI} !-d