Server Side Includes
|
Server Side Includes or SSI is an easy server-side scripting language used almost exclusively for the web. As its name implies, its primary use is including the contents of one file in another.
SSI-enabled HTML files usually use the extension *.shtml
or, more rarely, *.shtm
.
Contents |
Basic syntax
SSI has a simple syntax: <!--#directive parameter=value parameter=value-->
. Directives are placed in HTML comments so that if SSI isn't enabled, users won't see SSI directives without viewing the source.
Directives
These are the most common SSI directives:
Directive | Parameters | Description | Example |
---|---|---|---|
include | file or virtual | This is probably the most used SSI directive, allowing the content of one document to be included in another. The virtual parameter, which specifies the file or script to be included, should be used instead of the file parameter. | <!--#include virtual="header.html"--> |
exec | cgi or cmd | If the cgi attribute is used, it should be the path to a CGI script to be executed. The PATH_INFO and QUERY_STRING of the current SSI script will be passed to the CGI script. include virtual should be used instead of exec cgi. If the cmd attribute is used, it should be a shell command to be executed. The output of the command will be included in the page. |
<!--#exec cgi="/cgi-bin/foo.cgi"--> or <!--#exec cmd="ls -l"--> |
External links
- Apache mod_include reference (http://httpd.apache.org/docs/mod/mod_include.html)
- Apache SSI tutorial (http://httpd.apache.org/docs/howto/ssi.html)
- Server-Side Includes (http://www.yourhtmlsource.com/sitemanagement/includes.html) tutorial
- Plain-English Guide to SSI (http://www.andreas.com/faq-ssi.html)