How to match subdirectories in RewriteCond?

Having trouble with regular regex for RewriteCond

RewriteCond %{REQUEST_URI} !^/foo/

It works as expected, i.e. it does not apply after rewriting to all URLs starting with / foo /.

RewriteCond %{REQUEST_URI} !^/foo/bar/

On the other hand, it does not work as I expect. URLs starting with / foo / bar / are still being rewritten.

How to enter the correct regular expression to exclude subdirectories?

+5
source share
1 answer

Maybe a new URL for internal rule redirection has been added to it. This flag does this. L

[...], RewriteRule ( ), , RewriteRule.

, URL- "/foo/bar", (. THE_REQUEST variable) :

RewriteCond %{THE_REQUEST} !^[A-Z]+\ /foo/bar/
RewriteRule
+7

All Articles