Apache LocationMatch regex behaviour does not seem correct

Solution 1:

It is possible to workaround it by using this configuration:

<VirtualHost 127.0.0.1:80>
   ServerName localhost

   <Location "/">
     Header set X-Intelligence "CLEVER"
   </Location>

   <LocationMatch "^/[^\.]+$">
     Header set X-Intelligence "STUPID"
   </LocationMatch>

   <LocationMatch "^/(main|about)$">
     Header set X-Intelligence "CLEVER"
   </LocationMatch>

</VirtualHost>

This way, the following requests work as expected:

# curl -I -L http://127.0.0.1/ 2> /dev/null | grep X-I
X-Intelligence: CLEVER

# curl -I -L http://127.0.0.1/foo 2> /dev/null | grep X-I
X-Intelligence: STUPID

# curl -I -L http://127.0.0.1/about 2> /dev/null | grep X-I
X-Intelligence: CLEVER