Book HomeWebmaster in a Nutshell, 3rd EditionSearch this book

13.2. Basic SSI Directives

All SSI directives have the format:

<!--#command parameter="value" ... -->

Each of the symbols is important; be careful not to forget the pound sign (#) or the dual dashes (--). Also, it is recommended that you place whitespace between the final arguments and the closing dashes to prevent it from being interpreted as part of an SSI argument.

Following is a list of the primary server-side directives, the parameters they take, and their function.

config

config errmsg|sizefmt|timefmt="string"

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 are bytes, or abbrev, 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 for more information.

echo

echo encoding="type" var="environment_variable"

Inserts value of special SSI variables, as well as other CGI environment variables. For example:

<H1>Welcome to my server at <!--#echo var="SERVER_NAME" 
-->...</H1>

Arguments

encoding
Optional. This option is available in Apache 1.3.2 and later. It specifies how special characters contained in the variable are parsed before being output. none means no encoding is performed. url performs URL-style encoding. entity is the default value, which performs simple entity encoding. The encoding parameter must come before the var parameter, and is only in effect within the current echo directive.

exec

exec cmd|cgi="string"

Executes external programs and inserts output in the current document.

Arguments

cmd
Any application on the host.

cgi
A CGI program.

For example:

<!--#exec cmd="/bin/finger $REMOTE_USER@$REMOTE_HOST"-->
This page has been accessed 
<!--#exec cgi="/cgi-bin/counter.pl"--> 
times.
flastmod

flastmod file="path"

Inserts the last modification date and time for a specified file.

The file was last modified on 
<!--#flastmod file="/mybook.ps"-->.

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 Section 13.4 later in this chapter.

fsize

fsize file|virtual="path"

Inserts the size of a specified file.

Arguments

file
Pathname relative to a document on the server.

virtual
Virtual path to a document on the server.

For example:

The size of the file is
<!--#fsize file="/mybook.ps"--> bytes.
<!--#fsize virtual="/personal/mydata.txt"-->
include

include file|virtual="path"

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 example:

<!--#include file="stuff.html" -->
<!--#include virtual="/personal/stuff.html"-->
printenv

printenv

Prints all environment variables on the server.

For example:

<!--#printenv-->
set

set var="name" value="value" 

Sets a server-side variable to a given value.

Arguments

name
The name of the variable.

value
The value to be assigned to the variable.

For example:

<!--#set name="myvar" value="activated"-->


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.