Server Side Includes

Server side includes (SSI) are special HTML comments that are interpreted by Penn State's HTTP servers. The comments are replaced by content that the HTTP server finds or generates. For example, the HTML comment:

        <!--#include file="example.txt" -->

is used in the following block:

      Hello, world!

You can download the example.txt file to see what it contains.

Including a file is useful. For example, you can use file includes to use the same HTML for headers and footers for a large set of HTML files. You can also reference dynamically generated content and server variables. The supported CGI page has examples of using virtual includes to include the output of CGI scripts. You can use standard CGI variables. For example, The HTML:

        <!--#echo var="REMOTE_HOST" -->

will produce the result:

which is the IP address that this HTTP server saw when you accessed this page. Note that it might not be the IP address of your client machine if you're using NAT,going through a proxy, or looking at a cached version.

Enabling SSI

While SSI is supported on all Penn State servers that serve user content. SSI must be enabled in each directory tree where you want to use it. You can enable SSI for a directory tree by adding a line like:

    AddHandler server-parsed .shtml

in the .htaccess in the directory at the top of the tree. The above line will enable SSI on files with the extension .shtml. If you want all of your .html files to be parsed as SSI files, then replace .shtml in the line above with .html.

Exec is Not Supported

For security reasons, SSI exec, the ability to run arbitrary commands on the HTTP server is not enabled. However, the include virtual mechanism provides similar functionality and is supported.

Further Reading

For more information about Server Side Includes, see the Apache 2.2 SSI documentation or the Apache 2.4 SSI documentation. Currently, is running Apache 2.2.