Apache 2.4.3 SSI if there are no variables?

I have a lot of files with slight differences. The included file contains this, which attempts to distinguish one part of a longer path:

<!--#if expr="${DOCUMENT_URI}=/internet/"-->Internet<!--#else-->Intranet<!--#endif-->

In the error log I get

AH01337: Failed to parse expr "$ {DOCUMENT_URI} = / internet /" in /opt/apache/htdocs/ssi/time.shtml: Analysis error near $$

I find many variations of this topic, for example, no brackets, parentheses around the inside of quotation marks, a space to the end of the comment or = ~, but nothing helps. There seems to be no debug setting for mod_include which will tell me what's wrong ...

Another option I found is

<!--#if expr='"${DOCUMENT_URI}"=~/internet/'-->

it makes no mistakes. But it always selects the else branch, as well as REQUEST_URIas if the variables were canceled. But I can respond to them. I also tried /.+internet.+/in case he bound it.

Since these are CGI variables, I also tried loading cgid_module - also not good.

+5
source share
5 answers

Starting with version 2.3.13, mod_include switched to the new ap_expr syntax for conditional expressions in #if flow controls.

Add a directive SSILegacyExprParser onto switch to the old syntax compatible with Apache HTTPD version 2.2.x and earlier.

http://httpd.apache.org/docs/current/mod/mod_include.html#ssilegacyexprparser

+7
source

, v("foo"), , Apache 2.4 (http://httpd.apache.org/docs/2.4/expr.html#examples) :

<!--#if expr="%{DOCUMENT_URI} =~ /internet/"-->Internet<!--#else-->Intranet<!--#endif-->

% $ =~ .

, .

( SSILegacyExprParser on, , 2.2.x. , - ..)

+2

Apache ap_expr. : Apache docs. , v .

0

, , .... ( - Apache 1 ):

<!--# if expr="\"$DOCUMENT_URI\"=/internet/" -->
0

I worked with:

 <!--#if expr='v("foo") = "bar"' -->
 foo is bar
 <!--#endif --> 

See Flow Controls

0
source

All Articles