How to match a Drupal path in Apache config My D8 site uses the usual convention in .htaccess to rewrite non-file requests to index.php:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php [L]


However, if I try to perform a location match in my Apache 2.4 httpd.conf virtualhost, it fails because it seems that REQUEST_URI is set to index.php.

&lt;Location /foo/bar&gt;
  #Directives that should fire when accessing /foo/bar but don't
&lt;/Location&gt;

&lt;Location /index.php&gt;
  #Directives that do fire when accessing /foo/bar
&lt;/Location&gt;


Any ideas for getting this to work?  I have tried:

&lt;If "%{REQUEST_URI} =~ m#^/foo/bar#"&gt;
  #Directives that should fire when accessing /foo/bar but don't
&lt;/If&gt;

&lt;If "%{REQUEST_URI} =~ m#^/index\.php#"&gt;
  #Directives that do fire when accessing /foo/bar
&lt;/If&gt;
The directive I was trying to insert was Require all granted.  I managed to achieve the same effect by proxy-passing requests for /foo/bar to another virtual host running on the same machine, but unreachable from outside.  That 2nd virtual host did not require auth, which achieved the same effect as Require all granted.

ProxyPass /foo/bar http://example.local/foo/bar
ProxyPassReverse /foo/bar http://example.local/foo/bar