【问题标题】:SSI includes not working on server but working locallySSI 包括不在服务器上工作但在本地工作
【发布时间】:2018-01-07 10:49:42
【问题描述】:

我正在使用 USBWebServer(Apache、PHP、MySql)在本地开发一个网站,我想使用 SSI,所以我可以包含页眉、页脚等内容。

在我的 .htaccess 中,我放置了以下指令:

Options +Includes

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

我有主 index.shtml,里面有指令:

<!--#include virtual="./files/navbar.shtml" -->
<!--#include virtual="./files/contact.shtml" -->

而且效果很好。

但是,当我将网站上传到我的网络服务器时,使用 .htaccess 中的相同指令,index.shtml 不能包含任何内容。

我目前的解决方法是将 index.shtml 更改为 index.php 并使用 php 包括:

<?php
virtual('./files/navbar.shtml');
?>

,但我想知道为什么 SSI 在服务器上不能按预期工作,我该怎么做才能使它与 .shtml 一起工作?

【问题讨论】:

    标签: php apache include ssi server-side-includes


    【解决方案1】:

    假设您服务器上的网络服务器是 2.x Apache: 您必须启用包含模块。如果您在服务器上有管理员权限,您可以通过以 root 身份执行来自己完成

    a2enmod include
    

    并使用“service apache2 restart”或“/etc/init.d/apache2 restart”重新启动网络服务。
    如果不是,您必须询问您的管理员或服务器提供商。 此外 .htaccess 的使用可能会受到服务器配置的限制,请查看是否配置了允许覆盖或类似选项(或再次:询问您的管理员)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-12
      • 2021-10-01
      • 2020-01-25
      • 2023-01-02
      • 2017-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多