I am editing the Apache conf for my site with If directive to set some headers (for example) but the string to match regular expression operator gives syntax issue.
For example:
<If "%{HTTP_USER_AGENT} =~ RBTools.*">
Header set test_header %{HTTP_USER_AGENT}e
Require all granted
MellonEnable "off"
</If>
gives syntax error on the If statement. I have tried to enclose it in many other ways like so:
<If "'%{HTTP_USER_AGENT}' =~ RBTools.*">
<If "%{HTTP_USER_AGENT} =~ 'RBTools.*'">
<If "'%{HTTP_USER_AGENT}' =~ 'RBTools.*'">
<If %{HTTP_USER_AGENT}' "=~" RBTools.*>
<If "%{HTTP_USER_AGENT}' '=~' RBTools.*">
with all the same syntax issue.
The expression is documented here: https://httpd.apache.org/docs/current/expr.html
What should be the correct syntax? The syntax doesn't complain when I use the string equality comparitor "=="