How to check if LocationMatch regex is working

apache-2.4regex

I have location match regex

ScriptAlias /script /var/www/somescript.bash
Action some-handler /script virtual
<LocationMatch "/(?:\w+:)?\/\/[^\/]+([^?#]+)/">
    SetHandler some-handler
</LocationMatch>

Now when test that regex https://regex101.com/r/lO0aV1/1 you can see that location is matched but somescript.bash is never executed.

mod_actions are on by the way.

In error log I do not see anything. In access log I got 404.

How can I check that this regex is working? Is there anyway that I can log that?

Best Answer

Make a CustomLog, with e.g.:

CustomLog "/var/log/httpd/mylog.log" "%h %l %u %t \"%r\" %>s %b what:%{INDICATOR_VAR}e"

and use SetEnv to set the INDICATOR_VAR:

<LocationMatch ...>
    SetEnv INDICATOR_VAR "OK"
</LocationMatch>
Related Topic