Basic SSI Directives
All SSI directives have the format:
<!--#command parameter(s)="argument"-->
Each of the symbols is important; be careful not to forget the pound sign (#
).
Following is a list of the primary Server Side Includes, the parameters they take, and what they do.
echo
Inserts value of special SSI variables, as well as other environment variables. For example:
<H1>Welcome to my server at <!--#echo var="SERVER_NAME"-->...</H1>
See also CGI Environment Variables, and "SSI Environment Variables" later in the current chapter.
include
Inserts text of document into current file.
Arguments
file
- Pathname relative to a document on the server.
virtual
- Virtual path to a document on the server.
For
<!--#include file="stuff.html"--> <!--#include virtual="/personal/stuff.html"-->
fsize
Inserts the size of a specified file.
The size of the file is <!--#fsize file="/mytutorial.ps"--> bytes.
flastmod
Inserts the last modification date and time for a specified file.
The file was last modified on <!--#flastmod file="/mytutorial.ps"-->bytes.
You can specify the format of the date and time returned using the config
directive with the timefmt
argument; timefmt
takes a wide range of values described in the section "Configurable Time Formats For SSI Output" later in this chapter.
exec
Executes external programs and inserts output in the current document.
Arguments
cmd
- Any application on the host.
cgi
- CGI program.
For example:
<!--#exec cmd="/bin/finger $REMOTE_USER@$REMOTE_HOST"--> This page has been accessed <!--#exec cgi="/cgi-bin/counter.pl"--> times.
config
Modifies various aspects of SSI.
Arguments
errmsg
- Default error message.
<!--#config errmsg="Error: File not found"-->
sizefmt
- Format for the size of the file (returned by the
fsize
directive). Acceptable values forsizefmt
arebytes
, orabbrev
, which rounds the file size to the nearest kilobyte. For example:<!--#config sizefmt="abbrev"-->
timefmt
- Format for times and dates. SSI offers a wide range of formats. See the section "Configurable Time Formats For SSI Output" later in this chapter.