vendredi 19 février 2021

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 :-)

Aucun commentaire:

Enregistrer un commentaire