Basic Server-side Include Syntax


<!--#function attribute="value" -->

At Lehigh, files to be parsed for SSI must be named "*.shtml"

Core Functions

The echo and include functions are the ones most commonly used.

Flow Control Functions

[may not be available, depending upon server version and configuration]

Echo

The only attribute for this function is var, which specifies the variable to use. Examples:

<!--#echo var="DATE_GMT" -->
<!--#echo var="HTTP_USER_AGENT" -->
 
 


Include

This can take either the file attribute (to specify the directory path to the included file) or the virtual attribute (to specify the URL, which must not contain a scheme or hostname portion, of the included file). The virtual attribute is preferred. Examples:

<!--#include virtual="/~inwww/seminar/advanced/afile.inc" -->
<!--#include virtual="afile.inc" -->
 


Config


This can take one of three attributes, depending upon the feature being configured. errmsg configures the message to display if an error is encountered while parsing the document. sizefmt configures the way file sizes are reported, and can take the values bytes or abbrev (this rounds to the nearest kilobyte). timefmt sets the format for dates and times. The value of this is a coded string, laying out the order and type of date and time units, as listed below. Examples:

<!--#config errmsg="Error! File not found!" -->
<!--#config sizefmt="abbrev" -->
<!--#config timefmt="%A, %B %e, %Y" -->

The date and time format codes (case matters) are:
 
 
Code Meaning Example
%a
%A
%b
%B
%d
%D
%e
%H
%I
%j
%m
%M
%p
%r
%S
%T
%U
%w
%y
%Y
%z
Abbreviated day of the week
Day of the week
Abbreviated month name
Month name
Date (day-of-month; with leading zero if required)
Date as "%m/%d/%y"
Date (day-of-month; no leading zero)
24-hour clock hour
12-hour clock hour
Decimal day of year (julian day)
Month number
Minutes
AM or PM
Time as "%I:%M:%S %p"
Seconds
24-hour time as "%H:%M:%S"
Week of the year (also %W)
Numeric day of the week (Sunday=0)
Year of the century
Year
Time zone
Sun
Sunday
Jan
January
01
07/19/65
1 (not 01)
13
01
148
11
08
AM
01:50:40 AM
09
20:15:30
37
2
98
1998
EST


See also the Apache SSI docs.