Server Side Includes
Summary:
You may have noticed as
you browse our support site, that many of our pages end with the
shtml extension instead of the more familiar html or htm. This
is because we use Server Side Includes (SSI). Used properly, the
SSI can help make your pages more responsive and can even help
make maintaining your site an easier task.
Put simply, SSI is sort of like using your HTML server as a cut
and paste editor. Here is basically what happens when your server
handles a request for an SSI document.
- The server reads the
document and parses (techie word for chops up and looks for special
instructions) it for directives. (another techie word for directions!)
- Follows the instructions
that it finds and merges their results into creating a finished
document.
- The document is then
sent to the client browser.
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.
Included on this page:
Introduction:
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.
How To Use SSI
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.
Examples and Resources
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" -->
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)
|