Home     SSI Lab     CSS Templates     CSS     Htaccess     Web Design     XHTML

X-SSI Lab

graphic-img   



Introduction to Server Side Includes

Bookmark with StumbleUpon
del.icio.us
Digg it
reddit
Furl
Spurl
ma.gnolia
Yahoo MyWeb
Windows Live
Sponsors

What are server side includes?

Basically server side includes are directives which you can place into your HTML (or other) documents to execute scripts or output, for example, environment variables or file statistics. Ok... that doesn't explain much so read on.

SSI are an Apache feature implemented by mod_include. This feature allows us to place special code 'elements' in our documents which will carry out certain actions as specified. When a page is sent from the server to the requesting client the page is scanned by the server for the SSI code elements and carry's out the required actions based on the code element.

Files with the extension .shtml (or others as explained later) are processed by the server for SSI.



What can SSI be used for?

SSI can be used for many great things! Their primary uses are to provide interactivity to a web site and to aid site maintenance!

For example, content which is common to all your web pages can be placed in a single document and then included on ALL your pages. To make any changes you only need to modify this source document!

This is ideal for site navigation or copyright notices which are usually on all pages. having this content in a single file means changes can be done very quickly without having to modify 10, 20 or 50 separate documents!


What else can it be used for?

Many things! Displaying document information such as document name, URI, last modified date, file size. Using the "echo command" you can 'echo' environmental variables, user information such as IP address or browser information! You can redirect visitors to a page depending on what browser version they are using. You can check what country they are from and display a custom message in their language! You can query and update a database or send an email, all without the use of a CGI script!!

There are almost endless uses for SSI. Believe me, if you can use them do! They are easy to learn and will save you hours of work maintaining your sites as well as making them more dynamic!


For a much better explanation of what SSI can be used for please check out:

The XSSI Library - http://ordersomewherechaos.com/~rosso/xssi/
SSI from the NCSA HTTPd - http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html
Chapter 5 from O'Reilly's book... - http://www.oreilly.com/openbook/cgi/ch05_01.html
Big Nose Bird.com's excellent guide - http://www.bignosebird.com/ssi.shtml