2

My website uses SSI (server-side includes) to check a condition (using #if expr) and return different HTML code based on whether the condition is true or false. This used to work fine for years until recently, my website started showing the error [an error occurred while processing this directive]. I found out that the expr syntax changed in newer versions of Apache httpd, so I assume that my hosting provider upgraded the Apache httpd recently and that caused the old syntax to break. The Apache httpd is now at version 2.4.29.

I managed to fix the problem temporarily by adding SSILegacyExprParser on to my .htaccess file to go back to the old syntax (thanks to this question). But I would like to find a permanent solution using the new syntax.

Here is the old syntax SSI code that works with SSILegacyExprParser on:

<!--#if expr="${thisDoc} = /impressum\.shtml/" -->
<li id="current">
<!--#else -->
<li>
<!--#endif -->

(The variable thisDoc has been set earlier.)

Here is the SSI code using the new ap_expr syntax that doesn't work. It shows [an error occurred while processing this directive] again. I was following the documentation at http://httpd.apache.org/docs/current/expr.html when writing this code:

<!--#if expr="%{thisDoc} =~ /impressum\.shtml/" -->
<li id="current">
<!--#else -->
<li>
<!--#endif -->

I've tried modifying the syntax in various ways, for example to avoid using regex matching and use exact string comparison instead, but that didn't work either. I couldn't get a single expression to work in the new syntax.

Why is the new syntax not working?

outofthecave
  • 477
  • 6
  • 15

0 Answers0