Forum Moderators: open
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Furthermore I use the virtual parameter instead of the file parameter, for example:
<!--#INCLUDE VIRTUAL="/filename.shtml" -->
You can even combine them. Most of my pages are in HTML, but I use PHP sometimes. With the line <!--#INCLUDE VIRTUAL="/file.php" --> the PHP file file.php is included and executed as PHP, although the calling file is a plain HTML file.
I think for many hosts only the second line is enough because SSI is enabled for .shtml extensions on most hosts.
This is the first thing to verify - many servers explicity do not enable SSI for security reasons, so make sure your host has it enabled, and you **will** need to use the .shtml extension. This separates the files that require parsing from the files that don't, which decreases server load.
Secondly, use include file for same-directory includes and include virtual for includes from other directories.
And last, the space after the include command is indeed important.
you **will** need to use the .shtml extension
I agree that enabling SSI for plain HTML causes the SSI parser to be used for all files, including those not containing SSI statements. But the topic was about adding a header / footer to pages, which makes me think the include statement will be used in many, if not all HTML files.
Enabling SSI for .html files has a great advantage for existent sites which already have a decent ranking in Google and other search engines. You don't have to change the url and therefore you won't lose your current SERP position. There is also no need to set up a set of 301 redirects from .html to .shtml to preserve incomming links.
In general if you have to develop a new site, .shtml is the better choice, but when changing an existing site to have a common header and footer I would recommend .html. Impact on server performance is now not such an issue anymore as in the early days. Many .html files you see on the net are in fact .php files with a proper rewrite rule in Apache or IIS.
This is different from the C/C++ language #include statement which is most of the time placed at the beginning of the file.