0

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.

<Location /foo/bar>
  #Directives that should fire when accessing /foo/bar but don't
</Location>

<Location /index.php>
  #Directives that do fire when accessing /foo/bar
</Location>

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

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

<If "%{REQUEST_URI} =~ m#^/index\.php#">
  #Directives that do fire when accessing /foo/bar
</If>

1 Answer 1

1

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.