【问题标题】:SSI IF Statement errorSSI IF 语句错误
【发布时间】:2014-06-20 16:51:53
【问题描述】:

我在使用 SSI 的 if 语句时遇到问题。我已经在两台计算机上重新安装了操作系统(一台使用 win7,另一台使用 win8)并在它们上安装了 WAMP。然后我把我的旧项目放在文件夹中。在我打开使用 SSI 的项目后,如果我收到以下错误消息:

[处理此指令时发生错误]

问题是,当我在工作和笔记本电脑上打开这些文件时,我没有丢失此错误。

之后我切换到 XAMPP,但再次遇到同样的错误。

我正在使用以下语句:

<!--#if expr="$DOCUMENT_NAME = home.html"-->
<body class="home">
<!--#else-->
<body>
<!--#endif-->

而且好像进入了if语句,因为它放了body类“.home”,然后是消息。

其他一切,但 if 语句有效。我已将 header.shtml 和 footer.shtml 分开,ssi 将它们加载到站点中。但是当我使用 if - 时,它会中断。

我不认为这是相关的,但以防万一 - 这就是我的 .htaccess 文件的样子:

Options +Includes
AddHandler server-parsed .shtml .html .htm

【问题讨论】:

    标签: apache xampp wamp ssi server-side-includes


    【解决方案1】:

    您还需要更改 httpd.conf 文件,因为 SSI 在 Apache 中默认未开启。

    找到 httpd.conf 文件的这一部分

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
    

    把它改成

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
    

    【讨论】:

    • 不。已经是这样了。 SSI 本身可以工作,但是 if 语句会导致问题。
    【解决方案2】:

    SSILegacyExprParser on 添加到您的.htaccess

    请参阅此link

    【讨论】:

      猜你喜欢
      • 2017-04-28
      • 2011-09-22
      • 2017-05-04
      • 2017-05-29
      • 2013-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      相关资源
      最近更新 更多