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!
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_/$_))" -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With