| |||
| |||
|
|
|
Home:
Support:
Manual:
SSI:
Server Side Includes (SSI) If you wish to use server side includes in a web page, the file name of that web page must have the .shtml extension (eg. index.shtml) SSI is a mechanism whereby you can have our server do something to your HTML before sending it to the browser. SSI does some of the same things CGI does. Some differences are that SSI doesn't handle forms but CGI is much more involved if you just want another file or the output of a program included in your document. Used properly, the SSI can help make your pages more responsive and can even help make maintaining your site an easier task. Put simply, SSI is sort of like using your HTML server as a cut and paste editor. Here is basically what happens when your server handles a request for an SSI document.
Closer Look (examples): For every page that you intend to use SSI on, you'll need to rename the page extension from the usual .htm or .html extensions to .shtml. For example, if you intend to use SSI on your main page, you need to rename your index.html to index.shtml. Now that the renaming issue is put behind, lets look at what SSI can do and some reasons why you would use it on your pages. Here are some of the most useful tasks you can do with SSI:
Displaying the last modified date of a web page: To display the last modified date of a web page, you need to add the following SSI code to it:
The result would be:
Displaying the current date and time: To display the current date and time, add the following SSI code to your web page:
The result would be:
Code: Output: 09/05/08 Output: 03:03:13
Output: This is probably one of the must useful features of SSI. It gives you the ability to include one document inside another. The SSI code for this is:
Put this code anywhere in your webpage, and test.htm will show up in it's place. Notice that the file does not have to be a ".htm" or ".html" file. The included file could also be a ".txt" file. You might ask what use would this have on your web site. Here's an example. Let's say you have some content that is repeated on many pages of your site like your contact information or even a menu bar. If you save that common content as an individual html or text file, and if you use SSI instead to include that content onto those pages, updating your contact information or adding items to your menu will become as easy as changing just that ONE file. Now, if you didn't use SSI to include that content, you would have to change EVERY single page the content appears on.
SSI also allows you to run a CGI script or command directly from your webpage. This is where SSI becomes very crucial in many cases. This is not a feature you would use by itself, but in conjunction with a CGI script you have installed. In many cases CGI scripts require that they be called directly from a webpage, which only SSI can do. Basically, to get some of the CGI script to work for you, you must use SSI. The SSI code to call a CGI script from the webpage is:
Notice that you only use this command when the CGI script requires the use of SSI to function. Additional Documentation You can find additional in depth documentation about SSI at http://cgi.resourceindex.com/Documentation/Server_Side_Includes/
|