[英]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 中,我可以使用开关盒来使用简单的 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?但是如何查找 SSI?
My not working example: (Note: SSI is working with my Apache;-) )我不工作的例子:(注意:SSI 正在使用我的 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...好的,我发现以下 .htaccess 和我的示例工作...
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.您不需要为此打开旧版解析器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.