简体   繁体   中英

SSI includes not working on server but working locally

I'm developing a website locally with USBWebServer (Apache, PHP, MySql) and I wanted to use SSI, so I could include stuff like header, footer and so on.

In my .htaccess I have put following directives:

Options +Includes

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

I have main index.shtml and inside it I have directives:

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

and it works just fine.

However, when I upload site to my webserver, with the same directives in .htaccess, index.shtml cannot include anything.

My current workaround is to change index.shtml to index.php and to use php includes like:

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

, but I would like to know why SSI doesn't work as expected on the server and what can I do to make it work with .shtml?

Assuming that the webserver on you server is an 2.x Apache: You have to enable the Include-module. If you have admin-rights on the server you can do it yourself by executing as root

a2enmod include

and restarting the webservice with "service apache2 restart" or "/etc/init.d/apache2 restart".
If not than you have to ask your admin or serverprovider. Also the usage of .htaccess may be limited by the server configuration, see if allow overide or similar options are configured (or again: ask your admin).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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