Navigate
Sponsors
|
SSI Conditional Expressions - Flow Control ElementsIntroductionSSI allows conditional processing and provides a number of elements for this purpose. The basic flow control elements are:
<!--#if expr="test_condition" --> The #IF element works like an IF statement in programming. The test condition is evaluated and if the result is true then the text/lines following the IF statement is returned in the output until either on #ELIF, #ELSE or #END element is reached. The #ELIF and #ELSE elements are used to output text/lines if the original #IF statement was false. If #ELIF is parsed the SSI will continue until either an #ELSE or #END element is reached, and if an #ELSE statement is parsed the SSI will continue until an #END element is reached. The #END element closes the #IF element and must always be present or an error will likely occur. The test_condition from the flow control code above is one of the following:
"=" and "!=" bind more tightly than "&&" and "||". "!" binds most tightly. Anything that is not recognisable as a variable or an operator is treated as a string. To ensure your variable is treated as a variable you should use the format ${var_name} If a string is written as /string/ it will be treated as a regular expression so to test something of the form /home/path you will need to use an escape sequence \"/home/path\". Using the above information you can create quite complex tests. Here's a simple example to get you started:
<!--#if expr="(${HTTP_USER_AGENT} = /Mozilla\/4/) && |
||||||||||||||||||||