NOTE: In order to use Server Side Includes, your server must be configured to support them. Check with your system administrator as to whether or not you can use them, and if so, what restrictions may be placed on them. If you are not allowed to do SSI- consider moving to someplace where you can!
WHAT IS SSI? Server Side Includes (SSI) are commands executed by the server as it parses (chops up and looks for special instructions) the HTML file. SSI can be used to include the value of various server environment variables within your HTML such as the local date and time, to add in a footer or header, or embed an executable script. HTML files which contain SSI are often named *.shtml or *.shtm.
Here is basically what happens when your server handles a request for an SSI document:
The server reads the document and parses it for directives (another word for directions). It then follows the instructions that it finds and merges their results into creating a finished document. The document is then sent to the client browser.
If you are really concerned about presenting dynamic content in a uniform manner across most browsers, this method is preferred over "client-side scripting" such as javascript, where there are great variations in how differnt browsers handle the same coding.
Examples:- Adding Date and Time
To use SSI to place a time and date on the document use the following.
This will place the date and time of the current server location.
This may not be good because the time will conflict with other time zones.
To just display the date without the time, use:
- Include Header/Footer
To add a header and footer to the document, use the following:
At the top of the document:
At the bottom of the document:
To include a file from a different directory, use the following:
At the top of the document:
At the bottom of the document:
You use this type of include if you are using the low-overhead setting for active.cgi:
- Executing a CGI Script
To use SSI to execute a CGI script on the document use the following.
This will execute the cgi script "script.pl"
UBBDev.com uses this method to include active.cgi and slashubb.cgi to their front page:
- note: be sure and use the same general format for your SSI includes found here when you build your own page, including spacing, quotation marks, path to your cgi file, etc...
Warning:Improper use of SSI may impair server performance as well as server security. Consult with your server administrator before executing Server Side Includes.
Credits: http://www.bignosebird.com/ssi.shtml (get basics to complex info on SSI here)
http://www.builder.com/Authoring/MoreStupid/ss04.html (good info as well)
(others I can't remember)