Specifically for use on www.morris.umn.edu,
but applicable at any site using standard include syntax.
[ Overview
| Creating a SSI Document
| Using SSI Directives
]
[ SSI Directives
| SSI Environment Variables
]
Overview
Server Side Includes (SSI) allow dynamically changing web pages to be
created. SSI can be as simple as inserting the current time or another
text file into a web page and powerful enough to include the output of
commands or cgi programs. Basically, SSI allow a degree of flexibility
that is unatainable with static html
documents. That flexibility comes at a cost of increasing the server
load, so please make an effort to use SSI responsibly. Avoid on the fly
Povray renderings for example :-)
For your information, SSI were first
popularized in the NSCA, httpd webserver, and much of this information
comes from the NCSA SSI
tutorial.
Step 1: Create the HTML file that will use SSI
Step 2: Add the SSI directives to the HTML file
include inserts a file into the web page. All access permissions
still apply to the file and file includes are recursive, so SSI
directives in the included file will be processed also.
The include directive accepts either a "virtual" or a "file" argument.
virtual is a virtual path from the document root of the webserver. file
is a path to a file that is relative to the current document. file
doesn't allow ../ or full paths, e.g. /dir /file, to be used.
exec places the output of a command into the web page. The two
possible arguments to the exec directive are cmd and cgi. cmd will use
the sh shell to run the command. cgi will execute the given virtual path
to a cgi script and return the output
flastmod prints the last modification date of a file. The
arguments that can be used are the same as for the include directive.
The output formatting is set by the timefmt config parameter.
fsize prints the size of a file. The
arguments that can be used are the same as for the include directive.
The output formatting is set by the sizefmt config parameter.
config controls various aspects of parsing and the formatting of
certain information. There are three possible arguments:
SSI Environment Variables
The UMM WWW Page -- University of Minnesota, Morris
Please e-mail questions or comments to:
On www.morris.umn.edu, files that use SSI, need to end with the suffix
.shtml, e.g. index.shtml. This specific suffix tells the web server to
parse the file each time it is viewed and process the SSI directives.
If you are adding SSI to an existing web page, you can just rename the
previous file to end with .shtml mv index.html
index.shtml",
SSI directives are formatted as HTML comments. For example,
<!--#echo var=DATE_LOCAL-->
will insert the current local time
Format: <!--#include [virtual | file]="some_file"-->
Example: <!--#include file="sample.txt"-->
Result: This is the content of sample.txt
Format: <!--#exec [cmd | cgi] = "executable program"-->
Example: <!--#exec cmd="uptime"-->
Result: 08:37:06 up 6 days, 2:01, 3 users, load average: 0.25, 0.23, 0.19
Format: <!--#flastmod [virtual | file] = "filename"-->
Example: <!--#flastmod file="ssi.shtml"-->
Result: Monday, 22-Aug-2005 13:20:54 CDT
Format: <!--#fsize [virtual | file] = "filename"-->
Example: <!--#fsize virtual="/index.html"-->
Result: [an error occurred while processing this directive]
Format: <!--#config argument="value"-->
Example: <!--#config timefmt="%A, %B %d, %Y"-->
Result: Displays the date as Wednesday, November 25, 2009
The following variables are available for the echo SSI directive
to access in addition to the standard CGI environment variable set. Look
at the complete list of environment variables for
more information.
DOCUMENT_NAME
DOCUMENT_URI
QUERY_STRING_UNESCAPED
DATE_LOCAL
DATE_GMT
LAST_MODIFIED
Copyright 1996 University of Minnesota, Morris
Last Updated: January 8, 1996
Page URL: http://www.morris.umn.edu/committees/wwwac/toolbox/ssi.shtml
Nancy Mooney - Group Chair
or
The entire UMM WWW Advisory Group