KB 456
How do I use Server Side Includes
Article:456 Created:2007-03-17 14:18:20 Categories: Web Publishing Sys Admin
Question or Symptom
You want to know what Server Side Includes (SSI) are, and how do you use them on your website hosted at SWCP.
Resolution
SSI (Server Side Includes) are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. They let you add dynamically generated content to an existing HTML page, without having to serve the entire page via a CGI program, or other dynamic technology.
The decision of when to use SSI, and when to have your page entirely generated by
some program, is usually a matter of how much of the page is static, and how much
needs to be recalculated every time the page is served. SSI is a great way to add
small pieces of information, such as the current time. But if a majority of your
page is being generated at the time that it is served, you need to look for some
other solution.
Some common, easy to use SS directives are:
- <--#echo var="DATE_LOCAL" --> To display the current date in the page.
<!--#flastmod file="index.html" --> To display the modifcation date of a file. <!--#include file="somefile.html" --> Usually used to include something that
repeats on many pages, such as a standard hearder or footer.
For the SSI to work, the HMTL file must end in .shtml, as in example.shtml.
SSI can also be used to execute an external CGI script and display the output. To use this feature with SWCP web hosting you must do 2 things. First, you must use the "include virtual" syntax.
Second, you must put the script in your cgi-bin directory, and call it with your
script alias, just like you would call a CGI script from a form. For example,
user johndoe wants to use SSI to execute the script cutequote.pl. He would put
the script in /users/johndoe/public_html/cgi-bin. Then in his web page, he'd
use this: