Authoring/Development - Server Side Includes
What are Server-Side Includes?
Server side includes (referred to hereafter as SSI) are special codes which you can include in your HTML that cause the Web server to alter the page before sending it to the user's browser. They are available to users who hold accounts at the Basic level and higher.
SSI can be used to include a file, display the last modified time of the file (and other variables), and even to run CGI scripts (if your account type supports custom CGI scripts).
How do I enable SSI?
Files that include SSI codes should be saved with the file extension .shtml (index.shtml, for instance). This file extension tells the Web server to search the file for SSI codes before sending it to the user.
Please note that you do not have to change the file extensions on all of your files. You can simply add the following to your .htaccess file:
AddHandler server-parsed .myext
SSI Code Format
SSI Commands usually consist of an element, and one or more attributes and their values, in the format:
<!--#element attribute=value -->
After the final attribute value and before the ending --> there should be a space. Often the command will work if the space is not there, but it is given in the specifications and can occasionally cause problems if not present, so you should remember to always add it.
Including a File With SSI
The most common use for SSI is probably including a file within your page. This could be used to have a common footer on every page, for instance, while still being able to change it by altering a single file.
Including a file via SSI is done like:
<!--#include virtual="/filename.html" -->
The value of the "virtual" attribute should be the URL needed to view the file under your domain name, but without the domain name or "http://". For instance, if the file to be included is located at http://www.example.com/includes/first.txt, your call to include it in other files under that domain name would be:
<!--#include virtual="/includes/first.txt" -->
Showing The Last Modified Date With SSI
SSI can also be used to output the last modification date of the page. This is done by using the "echo" element and the LAST_MODIFIED variable. The command would be:
<!--#echo var="LAST_MODIFIED" -->
Other information that can be output in this fashion include DATE_LOCAL (date in the server's time zone -- United States Eastern time), DATE_GMT (date in Greenwich Mean Time), and DOCUMENT_NAME (the filename of the document).
Executing a CGI Script via SSI
Users with accounts at the Basic level and higher may choose to use SSI to include the output of a CGI script within a Web page. The SSI code to do this is:
<!--#exec cgi="/cgi-bin/included_script.cgi" -->
If you're using cgiwrap, you'll need to use this format instead:
<!--#include virtual="/cgi-sys/cgiwrap/username/included_script.cgi" -->
The method of determining the value of the "cgi" or "virtual" attribute is the same as with included files. If the complete URL of the script was:
http://www.example.com/cgi-bin/script.pl
then the path within the SSI code would be:
/cgi-bin/script.pl
Additional Resources
To learn more about server side includes with the Apache Web server, please read the documentation available at Apache.org




