[英]switch case (or if else) to load a file with include in SSI and QUERY_STRING?
在 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;
}
?>
但是如何查找 SSI?
我不工作的例子:(注意: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 -->
我只收到一条错误消息:
[an error occurred while processing this directive]
先感谢您:-)
好的,我发现以下 .htaccess 和我的示例工作...
SSILegacyExprParser on
但是存在一个有效的代码而不使用这个片段?
资料来源:
尝试使用
<!--#if expr="v('QUERY_STRING') = '/example1'" -->
您不需要为此打开旧版解析器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.