Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the World Wide Web. It is most useful for including the contents of one or more files into a web page on a web server (see below), using its <code>#include</code> directive. This could commonly be a common piece of code throughout a site, such as a page header, a page footer and a navigation menu. SSI also contains control directives for conditional features and directives for calling external programs. It is supported by Apache, LiteSpeed, nginx, IIS as well as W3C's Jigsaw. It has its roots in NCSA HTTPd.

Design

As a simple programming language, SSI supports only one type: text. Its control flow is rather simple, choice is supported, but loops are not natively supported and can only be done by recursion using include or using HTTP redirect. The simple design of the language makes it easier to learn and use than most server-side scripting languages, while complicated server-side processing is often done with one of the more feature-rich programming languages. SSI is Turing complete.

SSI has a simple syntax: <code>&lt;!--#directive parameter=value parameter=value --&gt;</code>. Directives are placed in HTML comments so that if SSI is not enabled, users will not see the SSI directives on the page, unless they look at its source. Note that the syntax does not allow spaces between the leading "&lt;!--" and the directive. Apache tutorial on SSI stipulates the format requires a space character before the "-->" that closes the element.

Examples

A web page containing a daily quotation could include the quotation by placing the following code into the file of the web page:

<syntaxhighlight lang="xml">

<!--#include virtual="../quote.txt" -->

</syntaxhighlight>

With one change of the <code>quote.txt</code> file, all pages that include the file will display the latest daily quotation. The inclusion is not limited to files, and may also be the text output from a program, or the value of a system variable such as the current time.

Directives

Common

The following are SSI directives from the times of NCSA HTTPd (the 1990s). Some implementations do not support all of them.

{| class="wikitable"

|+NCSA HTTPd SSI directives

|-

! Directive

! Parameters

! Description

! Example

|-

| <code>include</code>

| file or virtual

| This is probably the most used SSI directive. It allows the content of one document to be transcluded in another. The included document can itself be another SSI-enabled file. The <code>file</code> or <code>virtual</code> parameters specify the file (HTML page, text file, script, etc.) to be included. NCSA HTTPd did not support CGI via <code>include</code>, If the process does not have access to read the file or execute the script, the include will fail. The parameter "<code>virtual</code>" handles any directory paths as if part of the URL, while "<code>file</code>" handles any directory paths as in the underlying filesystem. When using "<code>file</code>" it is forbidden to reference absolute paths or <code>../</code> to access a parent directory. The Apache documentation recommends using "<code>virtual</code>" in preference to "<code>file</code>". Nginx

|-

| <code>printenv</code>

| &nbsp;

| This directive outputs a list of all SSI variables and their values, including environmental and user-defined variables. It has no attributes.

| <pre style="white-space:pre"><nowiki><!--#printenv --></nowiki></pre>

| Apache