繁体   English   中英

SSI包括不在服务器上工作但在本地工作

[英]SSI includes not working on server but working locally

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

在我的.htaccess文件中,我输入了以下指令:

Options +Includes

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

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

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

而且效果很好。

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

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

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

,但是我想知道为什么SSI无法在服务器上按预期方式工作,以及如何使其与.shtml一起使用?

假设您服务器上的Web服务器是2.x Apache:您必须启用Include-module。 如果您在服务器上具有管理员权限,则可以通过以root用户身份执行自己来执行此操作

a2enmod include

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM