Server Side Includes

Back

Introduction

Server Side Includes, or SSI for short, are a special kind of codes that you can include in your HTML documents to make them a little more dynamic. And luckily, WWW Server has a plugin which provides support for them.

Using SSI

After installation, there are a few new tags that you can use in your documents. These are the following:

<!-#echo var="DATE_LOCAL"-> is replaced by the current date and time,

<!-#echo var="LAST_MODIFIED"-> is replaced by the date and time of the last modification of the file,

<!-#echo var="DOCUMENT_URI"-> is replaced by the virtual file name of the file, e.g. /folder/document.shtml,

<!-#include file="FILENAME"-> is replaced by the contents of the specified file. FILENAME should be replaced by a local path name, an example of the usage of this directive is:

<!-#include file="C:\Website\footer.inc">

The specified file will be retrieved through the server, and is handled almost the same as if it were requested the normal way. Thus, it makes perfectly sense to include a PHP file. The only difference is, that in this case the request information sent to the PHP plugin would be the information about the SSI file. Especially, $_SERVER['PHP_SELF'] would contain the URL of the SSI file, not that of the included PHP file; the same applies to $_SERVER['SCRIPT_NAME'].

The included file will be interpreted for Server Side Includes as well. This way, you can easily create a footer include which contains both a standard copyright text and the last modification date.

Of course, it is also possible to make the SSI plugin postprocess the output of a PHP script, etc.

Pitfalls

For some reason, the SSI Plugin has been a bit like an ugly duckling, so there are some things that you need to watch out for:

Make sure that, after installation of the SSI plugin, you make the default plugin accept .shtm and .shtml files, and do not forget to alter the file name of your SSI containing pages, so that these end in one of those extensions.

The DOCUMENT_URI variabele is only supported with SSI Plugin version Raai.1 and above.

Initially the SSI plugin was buggy. Only the most recent versions, Compieuw.2 and Raai.1, work properly.