简体   繁体   中英

switch case (or if else) to load a file with include in SSI and QUERY_STRING?

In PHP I can use switch case for using a simple function:

<?php
switch($_SERVER['QUERY_STRING']) {

case 'example1':
include 'example1.php';
break;

case 'example2':
include 'example2.php';
break;

case 'example3':
include 'example3.php';
break;

default:
include 'example1.php';
break;
}
?>

But how look it for SSI?

My not working example: (Note: SSI is working with my Apache;-) )

<!--#if expr="$QUERY_STRING = 'example1'" -->
    <!--#include virtual="example1.html" -->
<!--#elif expr="$QUERY_STRING = 'example2'" -->
    <!--#include virtual="example2.html" -->
<!--#elif expr="$QUERY_STRING = 'example3'" -->
    <!--#include virtual="example3.html" -->
<!--#else -->
    <!--#include virtual="example1.html" -->
<!--#endif -->

I get only an error message:

[an error occurred while processing this directive]

Thank you in advance:-)

OK, I found following for .htaccess and my example works...

SSILegacyExprParser on

But exist a valid code without to use this snippet?

Sources :

Try using

<!--#if expr="v('QUERY_STRING') = '/example1'" -->

You shouldn't need the legacy parser turned on for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM