IntroductionWhat is SSI
What you need
Setting up SSI
If / Then / Else
Welcome to the Server Side Includes GUIDE!November, 2001
(C)opyright 2001, By Geoff Knagge
You are free to copy, mirror or otherwise publish this guide on the condition that you provide credit to me by name, and preferably with a link to, or the address of, this site.
This is intended as a guide only. Although I have worked closely with the available specifications while I made this guide, it should not be considered as official documentation of server side includes. I cannot, and do not, guarantee that this guide is free from errors.
What are Server Side Includes?As the name suggests, these special html commands are used to tell the web server to generate certain information immediately before sending the page to whoever wants to view it. This might include :
** HTML head section start, and title ** ** The next line sets up the page layout ** <!--#include virtual="/templates/guideheader.t" --> ** The next file writes the contents column ** <!--#include virtual="contents.htm" --> ** The next file ends the first column and starts the info panel ** <!--#include virtual="/templates/endguidecontents.t" --> ** the contents of this information panel go here ** ** This file finishes off the page ** <!--#include virtual="/templates/footer.t" -->
What do I do to be able to use these?To be able to use server side includes in your own web pages, whoever is hosting your web page must enable an option that allows you to do so. For various reasons, the web space available with free providers and those that come with your ISP account generally don't allow SSI for various reasons. Hence, your only hope of being able to use them is to pay for web hosting with this option, or to run your own server. In the latter case, see the next section for how to enable SSI.
Assuming that you have access to SSI, all you have to do is to make the files. Generally, web pages that use SSI have a special extension, .shtml instead of the usual .htm or .html. Apart from this, just insert the special HTML tags and everything else is the same as normal. Note that sometimes the server may be configured to use something other than .shtml, in which case you will have to find out from that service provider.
Upon requesting a .SHTML file, the web server will recognize the extension and search the file for these special tags. For any that it recognises, it will replace them with the required information.
Setting up the Apache Web Server for SSIThis section is specifically for the Apache web server, but others should be configurable in a similar way. Whatever the case, it'll be in the documentation somewhere...
To use SSI in Apache, first it must have the mod_include module installed. Apache 1.3 comes with this, but it is not enabled by default. To enable them, the following two lines must appear in the
AddType text/html .shtml AddHandler server-parsed .shtmlAccoring to the documentation, you also need to have
The only other thing you may wish to do is to make it look for index.shtml files as the default when no file in the directory is specified. This involved changing the line
After making these changes, you will need to restart Apache:
apache -k restart