Server Side Includes at the UW
Server Side Includes (SSI) let you create Web pages which are generated dynamically each time they are requested by a Web browser. All you have to do is embed SSI commands into your HTML. SSI's ease the maintenance of large Web sites by providing a way to insert the contents of a single file into several Web pages.
Server Side Includes (SSI) can be used to:
- Include headers and footers on several Web pages
- Include a last modification date on a Web page
- Include the output of a CGI program in a Web page
- Use conditional tests to generate Web page content
SSI commands are embedded in your HTML as comments. They are parsed by the server when a file is requested by a Web browser.
By default, HTML files are not parsed for SSI commands. To use SSI commands in a file, use a .shtml filename extension. For example, if you put SSI commands in your home page, it should be renamed index.shtml.
Here are several simple SSI command examples:
Include the contents of another file
<!--#include file="header.html" -->
Include last modification date
<!--#echo var="LAST_MODIFIED" -->
Include last modification date of another file
<!--#flastmod file="resume.html" -->
Include the contents of a CGI program
<!--#exec cgi="id.cgi" -->
Note: the cmd attribute for the exec SSI element has been disabled. Use the cgi attribute instead.
To learn more about SSI and individual SSI commands see:
- Introduction to Server Side Includes (an Apache tutorial)
- Using Server Side Includes (from Apache Week)
- Module mod_include (from Apache documentation)