7

This is doing my nut in. I'm trying to get server side includes to work. The server I'm hosting my site on has SSI enabled and the company that owns the servers said my issue is to do with my code, not to do with their servers.

Here's my file called test.html

<!DOCTYPE html>

<html lang="en">
<head>

<meta charset="utf-8">


</head>
<body>

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

</body>
</html>

The file top.html is just a bunch of html, nothing wrong there.

When I call the main file test.shtml it works fine. When I call it test.html it doesn't. When I googled this, it said it's to do with file parsing. How is this anything to do with the code? What can I do to make it work with the .html file extension. (I can't use .shtml for SEO reasons).

CaribouCode
  • 13,998
  • 28
  • 102
  • 174
  • I guess all I need to do is get the server to parse .html files. Anyone know how I do this. Is it to do with .htaccess? If so, how on earth do I do that? – CaribouCode Oct 09 '12 at 19:02

2 Answers2

8

Add the following commands to the .htaccess file:

# Enable server side includes
Options +Includes 

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

References

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
-1

I had the same issue. Now I use xampp and I've added these lines before VirtualHost declarations

<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>

Hope this help