Reputation: 11275
Some of the expressions in Server Side Include are no longer working after I upgraded the server from version 2.2 to 2.4, giving me a series of errors:
AH01337: Could not parse expr "$SERVER_NAME = abc" in /var/www/err/ft.html.var: Parse error near '$'
AH01337: Could not parse expr "! $REDIRECT_STATUS" in /var/www/err/tp.html: Parse error near '$'
AH01337: Could not parse expr "$HTTP_HOST = /^([a-z]{2}\.)abc\.com/ && $SERVER_NAME = abc\.com" in /var/www/err/tp.html: Parse error near '$'
I understand that this is due to some ongoing effort to only use a single variant, called ap_expr, for all configuration directives. However, after reading the documentation, I still have no idea how to convert some of my old code to reflect this change:
<!--#if expr="! $REDIRECT_STATUS" -->
<!--#set var="REDIRECT_STATUS" value="404" -->
<!--#endif -->
<!--#if expr="$HTTP_HOST = /^([a-z]{2}\.)abc\.com/ && $SERVER_NAME = abc\.com" -->
<!--#set var="subdomain" value="$1" -->
<!--#else -->
<!--#set var="subdomain" value="" -->
<!--#endif -->
Would appreciate if somebody can point out how the above would be changed to get me started. Thanks!
Upvotes: 6
Views: 5619
Reputation: 1
Change this: <!--#if expr="! $REDIRECT_STATUS" -->
To This: <!--#if expr="-z v('REDIRECT_STATUS')" -->
Source is a example from newer code (my error was in top.html): https://fossies.org/windows/www/httpd-2.4.54-win64-VS16.zip/Apache24/error/include/top.html
Upvotes: 0
Reputation: 4373
I'd expect that if you interested in the new syntax, you'll end up with something like this:
<!--#if expr="-z %{REDIRECT_STATUS}" -->
<!--#set var="REDIRECT_STATUS" value="404" -->
<!--#endif -->
<!--#if expr="v('HTTP_HOST') =~ /^([a-z]{2}[.])abc[.]com/
&& v('SERVER_NAME') == 'abc.com'" -->
<!--#set var="subdomain" value="$1" -->
<!--#else -->
<!--#set var="subdomain" value="" -->
<!--#endif -->
I'm not sure about the $1, since I didn't have such a use in what I just converted last night (a few folks think it may only be usable within the same expr it's captured in). I've found some issues with the regular expressions NOT working like expected, for example, an expression like this one to determine if I'm looking at what amounts to the current directory or a sub-document works. The last line does match a URI ending in "/", but I lost a few hours discovering that the %{REQUEST_URI} will NOT work, only the v('REQUEST_URI') form (somehow I'm expecting to find the reverse true for something).
<!--#if expr="((v('REQUEST_URI') =~ m_/index.shtml_)
|| (v('REQUEST_URI') =~ m_/index.html_)
|| (v('REQUEST_URI') =~ m_/index.cgi_)
|| (v('REQUEST_URI') =~ m_/$_))" -->
Upvotes: 2
Reputation: 294
WARNING
I did try to activate directive :
SSILegacyExprParser on
(as mentioned in comment above)
BUT that also killed my SSIStartTag configs..
No more nice {{echo var='var1'}}
Beware that XHTML editors will CHOKE if the OLD comment syntax appear inside attributes >:-(
Upvotes: 1