【问题标题】:Basic SSI not working基本 SSI 不起作用
【发布时间】:2012-09-30 03:43:29
【问题描述】:

这让我很生气。 我正在尝试让服务器端包含工作。我托管我的网站的服务器启用了 SSI,拥有服务器的公司表示我的问题与我的代码有关,而不是与他们的服务器有关。

这是我的名为 test.html 的文件

<!DOCTYPE html>

<html lang="en">
<head>

<meta charset="utf-8">


</head>
<body>

<!--#include file="assets/includes/top.html" -->

</body>
</html>

文件top.html只是一堆html,没有错。

当我调用主文件 test.shtml 时,它工作正常。当我称它为 test.html 时,它没有。 当我用谷歌搜索时,它说这与文件解析有关。这与代码有什么关系?我该怎么做才能使其与 .html 文件扩展名一起使用。 (出于 SEO 的原因,我不能使用 .shtml)。

【问题讨论】:

  • 我想我需要做的就是让服务器解析 .html 文件。任何人都知道我是如何做到这一点的。它与.htaccess有关吗?如果是这样,我到底该怎么做?

标签: ssi


【解决方案1】:

将以下命令添加到.htaccess 文件中:

# Enable server side includes
Options +Includes 

# pass .html files to the server for parsing
AddHandler server-parsed .html 

参考文献

【讨论】:

    【解决方案2】:

    我有同样的问题。现在我使用 xampp,并在 VirtualHost 声明之前添加了这些行

    <Directory />
        Options FollowSymLinks Indexes Includes
        AllowOverride All
        Order allow,deny
        Allow from All
        Satisfy any
        AddType text/html .shtml .html .htm
        AddOutputFilter INCLUDES .shtml .html .htm
        <Limit PUT>
                Order allow,deny
                Deny from all
        </Limit>
    </Directory>
    

    希望有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-23
      • 2017-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多