More SSI Examples


echo prints one of the SSI or CGI variables. It's format is:
<!--#echo encoding="encode_type" var="an_envirnoment_varialbe"-->
  From version 1.3.12, Apache has included an encoding option to the echo SSI directive that specifies how Apache should encode special characters contained in the variable before they are output. none specifies no encoding. url indicates the %-encoding as used in URL's. The default in entity which encodes any special characters (<>&....) Only the special characters defined in ISO-8859-1 are encoded. To be effective the encoding pragma must precede the var pragma.

The SSI variables, meaning and their contents are:
The name of the current document <!--#echo var="DOCUMENT_NAME"--> more_ssi.shtml
The virtual path to the file <!--#echo var="DOCUMENT_URI"--> /apache/more_ssi.shtml
The virtual path to the file <!--#echo var="QUERY_STRING_UNESCAPED"--> (none)
Current date and time in the local time zone <!--#echo var="DATE_LOCAL"--> Tuesday, 24-Oct-2017 10:03:25 BST
Current date and time in Greenwich Mean Time <!--#echo var="DATE_GMT"--> Tuesday, 24-Oct-2017 09:03:25 GMT
Last modification date and time for current file <!--#echo var="LAST_MODIFIED"--> Saturday, 21-Oct-2006 11:24:29 BST
  The format of DATE_LOCAL, DATE_GMT, AND LAST_MODIFIED can be controlled by the timefmt pragma of config i.e.  
<!--#config timefmt="%A %B %m/%d/%y %H:%M:%S"-->
  would produce:  
<!--#echo var="DATE_LOCAL"--> Tuesday October 10/24/17 10:03:25
<!--#echo var="DATE_GMT"--> Tuesday October 10/24/17 09:03:25
<!--#echo var="LAST_MODIFIED"--> Saturday October 10/21/06 11:24:29


How big is that document?
<!--#fsize virtual="index.shtml"-->
  The size of index.shtml is: 3.1K

or if we would like to know in bytes:

<!--#config sizefmt="bytes"-->
  The size of index.shtml in bytes is: 3,151

It appears the default for fsize is abbrev

<!--#config sizefmt="abbrev"--> is the default.


We have already seen config used for timefmt and sizefmt You can also configure the error message Apache will display, if you make a mistake with SSIs. Instead of getting....
[an error occurred while processing this directive] 
  The errmsg can be set by config to display your own customised message.  
<!--#config errmsg="SSI Error, contact 
<a href=\"\">webmaster@jlk.netlt;/a>"-->
  I have wrapped the line for legibility, but you get the idea. When an SSI error occurs you would see  
SSI Error, contact

SSI Examples   RTFM Index   Running commands with SSI
Copyright © 2006 Open Source Migrations ltd. All Rights Reserved.
Apache RTFM last updated Saturday October 21 2006