SSI Examples

In no particular order.....

flastmod

File last mod(ified)... The date/time of the last modification of a file.

The      "Apache RTFM last updated ....."      information displayed at the bottom of each page of the RTFM is generated by the SSI directive:

 
<!--#config timefmt="%A %B %m/%d/%y"-->
Apache RTFM last updated <!--#flastmod virtual="rtfm.shtml"-->

  Everytime I update or amend the Apache RTFM, I edit rtfm.shtml to insure the date is changed to reflect the last modified date.

config

In the above example, I used the config option to set the date format. If I hadn't specified exactly what I wanted for the date, the results would have looked like this.
 
Apache RTFM last updated Saturday, 21-Oct-2006 11:24:29 BST
  Here is all the timefmt options and their output.  
Day of the week abbreviation <!--#config timefmt="%a"--> Sat
Day of the week <!--#config timefmt="%A"--> Saturday
Month name abbreviation <!--#config timefmt="%b"--> Oct
Month name <!--#config timefmt="%B"--> October
Date (1 and not 01) <!--#config timefmt="%d"--> 21
Date (%m %d %y)
<!--#config timefmt="%D"--> 10/21/06
Date <!--#config timefmt="%e"--> 21
24-hour clock <!--#config timefmt="%H"--> 11
12-hour clock <!--#config timefmt="%I"--> 11
Decimal day of the year <!--#config timefmt="%j"--> 294
Month (number) <!--#config timefmt="%m"--> 10
Minutes <!--#config timefmt="%M"--> 24
AM|PM <!--#config timefmt="%p"--> AM
Time as %I:%M:%S AM|PM <!--#config timefmt="%r"--> 11:24:29 AM
Seconds <!--#config timefmt="%S"--> 29
24 hr time as %h%m%s <!--#config timefmt="%T"--> 11:24:29
Week of year <!--#config timefmt="%U"--> 42
Day of week <!--#config timefmt="%w"--> 6
Year of century <!--#config timefmt="%y"--> 06
Year <!--#config timefmt="%Y"--> 2006
Time Zone <!--#config timefmt="%Z"--> BST
  NT users should note the following formats appear to be broken on the 1.3b3 version of Apache.  
Date (%m %d %y)
<!--#config timefmt="%D"-->
Date <!--#config timefmt="%e"-->
Time as %I:%M:%S AM|PM <!--#config timefmt="%r"-->
24 hr time as %h%m%s <!--#config timefmt="%T"-->
 

flastmod re-visited

In the example below, we have specified virtual
 
<!--#config timefmt="%A %B %m/%d/%y"-->
Apache RTFM last updated <!--#flastmod virtual="rtfm.shtml"-->

  fastmod can user either:
  • virtual or
  • file
The distinction is subtle. File allows you to specify a file relative to the current document, but ../ is not allowed. Virtual allows you to specify a file relative to Apache's document hierarchy. That doesn't help much! Let's try an example or two. Assume that Apache is installed in /var/apache and the DocumentRoot is /var/apache/htdocs.
 
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.

DocumentRoot "/var/apache/htdocs"
  In htdocs, we have the directory rtfm which contains foo.shtml and bar.shtml. In foo.shtml we want to display the last modified date of bar.shtml. bar.shtml can be referenced relative to foo.shtml with the file directive.  
<!--#flastmod file="bar.shtml"-->
  or we can reference it via the Apache document hierarchy using virtual  
<!--#flastmod virtual="/rtfm/bar.shtml"-->
  What does this mean for me? (other than virtual requires more typing!) Suppose you want get the last modified date for a file in the directory apache from foo.shtml. You could try:  
<!--#flastmod file="../apache/bar.shtml"-->
  and you would get:
 
[an error occurred while processing this directive] 
  since you cannot use "../" with either virtual or file. You could get the information by using:  
<!--#flastmod virtual="/apache/bar.shtml"-->
   


Configuring SSIs   RTFM Index   More SSI examples
Copyright © 2006 Open Source Migrations ltd. All Rights Reserved.
Apache RTFM last updated Saturday October 21 2006