Here is my mod_rewrite configuration:
RewriteEngine On
RewriteCond expr "true"
RewriteRule .? - [L]
RewriteRule ^(.*)$ $1 [QSA,L]
And here the relevant logging output:
RewriteCond: input='expr' pattern='true' => not-matched
The Apache documentation says
Syntax: RewriteCond TestString CondPattern
If the TestString has the special value
expr, the CondPattern will be
treated as an ap_expr.In the below example,
-strmatchis used to compare theREFERERagainst
the site hostname, to block unwanted hotlinking.
RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/*'"
RewriteRule ^/images - [F]
So if CondPattern will be treated as ap_expr and ap_expr can per definition explicitly be true then why the hell does the simplest possible expression fitting into that pattern not work? To be exact no matching expression works for me. Is anyone out there who can verify that this technique ever worked for anyone?
Because I actually have a pretty complex expression which can not be done with conventional mod_rewrite conditions, it is very important to me to know whether I can use this method anyhow.
EDIT:
For the lazy ones, here the BNF definition of ap_expr directly copied from here:
expr ::= "true" | "false"
| "!" expr
| expr "&&" expr
| expr "||" expr
| "(" expr ")"
| comp
Are you sure you’re using apache 2.4? The
ap_exprstuff is all new features that are part of the 2.4 feature set and not a part of 2.2.