SSI Commands

A brief list of Server Side Include commands

I've added this to my web site because I found it very hard to get this information when I needed it myself. I have included some links at the end of the page of some sites that I have found that do a more comprehensive job then here.

Command Parameter Argument Type Function
#config var Definition Allows to have field formats defined as requested
#echo var a SSI variable Echo, display, the value of the requested variable.
#include file file name Puts the contents of the names file inside the current file.

Config Command

Explanation

The config command allows you to specify the format that will be used for dates, times and file sizes and the text of the generic error message which will be sent to the client if an SSI processing error occurs.

Parameters

  • errmsg
What will be displayed if there is an error
  • sizefmt
When a variable requests returns a size, this allows you to define the format of the size
  • timefmt
When a date is being displayed you can define the format of the date using this config parameter Examples of the timefmt can be seen below

Example

<!--#config sizefmt="bytes" -->

The size of this file is :

Echo Command

Explanation

The echo SSI command. As extensions, it has the parameters "reqstate" (for echoing Jigsaw request states) and "reqheader" (for echoing request header).Also, it can take the flag "here", whose presence means that the variable is to be interpreted at the deepest request level (in the case of chained internal requests), instead of doing so at the top (external request) level. It inserts the value of a variable in the document.

Parameters

  • var = a SSI variable
  • reqstate = a Jigsaw request state
  • reqheader = a request header
  • here = a flag

Example

More examples of Echo below

<!--#echo var="DOCUMENT_URI" -->

display the document uri

Notice it is a "i", NCSA says "URI" most other people say "URL" but since they set up the standard, we have to do it their way


Include Command

Explanation

The SSI include command. (CGI scripts can be included, simply by providing a so-called virtual path to a resource with a CgiFrame).

Parameters

  • file = the file to include
  • virtual = a virtual path
  • ifheader = a request header
  • else = a file

Example

<!--#include file="included.html" -->

include the file "included.html" in the current file

<!--#include ifheader="Referer" file="included.html" else="included2.html" -->

if the request has a Referer header then include "included.html" else include "included2.html"


More examples of the Echo command

AUTH_TYPE Client authorization method if any

DATE_GMT The present date and time in Greenwich Mean Time. You can format the way the date is displayed by using standard unix date formats .. see below

DATE_LOCAL The current local time zone date and time.

DOCUMENT_NAME The name of the web page file being displayed.

LAST_MODIFIED The date and time of the last modification of the current file.

HTTP_USER_AGENT This returns the name of the browser being used.

REFERER the referer header of the request

CONTENT_LENGTH size of input posted from client

CONTENT_TYPE MIME type of content

DOCUMENT_URI URL of the document

PAGE_COUNT number of accesses to current document since server was brought on line

HTTP_REFERER URL of the document the client came from

REMOTE_ADDR Numeric IP address of the client

REMOTE_HOST domain name of the client (DNS option must be active on server)

REMOTE_USER ID of user, rarely ever found.

REQUEST_METHOD HTTP method: GET OR POST

SERVER_NAME server hostname.

SERVER_PORT the port used by httpd (usually 80)

SERVER_PROTOCOL Which version of Httpd compliance

SERVER_SOFTWARE The name of the server software.

TOTAL_HITS total pages served by server since brought on line

You can control the exact appearance of your time and date information by setting the timefmt using a config such as the one below. Just include this config before the actual include that calls the date.

<!--#config timefmt="%m/%d/%y" -->
Will give you today's date as

Note, this date is the date of the server, which is situated in New Zealand
!!We lead the world in dates!!

The complete list of unix style date format codes follow:

CODE PURPOSE OF CODE DISPLAYS
%a abbreviated weekday name

%A full weekday name

%b abbreviated month name

%B full month name

%c locale's appropriate date and time representation

%C default date and time format

%d day of month - 01 to 31

%D date as %m/%d/%y

%e day of month - 1 to 31 (single digits are preceded by a blank)

%h abbreviated month name (alias for %b)

%H hour - 00 to 23

%I hour - 01 to 12

%j day of year - 001 to 366

%m month of year - 01 to 12

%M minute - 00 to 59

%n insert a newline character
%p string containing AM or PM

%r time as %I:%M:%S %p

%R time as %H:%M

%S second - 00 to 61

%t insert a tab character
%T time as %H:%M:%S

%U week number of year (Sunday is the first day of the week) - 00 to 53

%w day of week - Sunday=0

%W week number of year (Monday is the first day of the week) - 00 to 53

%x Country-specific date format

%X Country-specific time format

%y year within century - 00 to 99

%Y year as CCYY (4 digits)

%Z timezone name

Other Sites that talk about SSI Commands.

These are the ones that I got my information from

Apache

Computer Technology Documentation Project

Internet Connection

The world kiosk

W3C