3.7 Setting Up Server-Side Includes

Server-side includes (SSIs) provide a means of adding dynamic content to existing HTML documents without the use of a CGI program or other dynamic technology.

SSIs are directives placed in HTML pages and evaluated on the server while the pages are being served. Wherever you add SSI directives within an HTML page, that is where the results of the SSI code show up. For example, you could embed the current date or time into a Web page by adding the following code to an existing HTML file:


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

SSI code appears like an HTML comment. However, if SSI is configured properly, Apache processes it as SSI code and in this sample, the current date appears on your Web page.

Before SSI codes are recognized by Apache, you must first enable it. You must also specify the file extension to use for files containing SSI directives. This helps Apache identify which files contain SSI.

On the Network Settings page:

  1. Click On next to Server-Side Includes.

  2. Specify the file extension to be used by files containing SSI directives.

    Typically, this is shtml, but you can specify any file extension you want, including simply html.

  3. Click Save > Save to save your changes.

    or

    Click Save > Save and Apply to save your changes and restart Apache so your changes are immediately put into effect.

    For information about where configuration information is stored, see Section 2.3.3, Saving Configuration Changes and Restarting Apache in Apache Manager.

For a more extensive discussion of SSI, see Apache Tutorial: Introduction to Server-Side Includes on the Apache Web site.