I want to check if a file exists with <!--#if expr='-F %{foo}' --> but apaches error.log says the variable wouldn't exist. <!--#echo var="foo" --> works fine.
I started in a file with hard coded values where it worked fine. Now I want to create a parameterized snippet I can include in several other files.
<!--#set var="foo" value="/path/to/file" -->
<!--#echo var="foo" --><br>
<!--#if expr='-F %{foo}' -->
exists<br>
<!--#else -->
doesn't exist<br>
<!--#endif -->
<!--#echo var="foo" -->
I'd expect the output
/path/to/file exists /path/to/file
but instead I get the error message saying that the variable wouldn't exist in apaches error.log:
AH01337: Could not parse expr "-F %{foo}": Variable 'foo' does not exist
it's not so 01337 if you'd ask me...
Having a look at the mod_include documentation about flow control and the Apache Expressions Syntax shows two things which might interfere here and cause this issue:
v("foo")syntax and not the%{foo}syntax to refer to variables (unlessSSILegacyExprParseris set toon, but the legacy syntax seems to be$fooanyways).%{…}syntax.So I assume that there are two different types of variables and only one (the server-provided variables) can be used with the
%{…}syntax. (And yes, these different ways to refer to a variable look confusing to me, too.)