SSI Variables

Just a few observations on variables and SSIs.

You don't use a $ with #echo

 
<!--#echo var="$HTTP_HOST"-->
  yeilds
(none)
  where as
Host name is: <!--#echo var="HTTP_HOST"-->
  gives you
Host name is: jlk.net
  but you do need a $ elsewhere  
<!--#set var="myvar" value="HTTP_HOST" -->
Host name is: <!--#echo var="myvar" -->
  yeilds...
Host name is: HTTP_HOST
  where as...
<!--#set var="myvar" value="$HTTP_HOST" -->
                            ^
Host name is: <!--#echo var="myvar" -->
  produces...
Host name is: jlk.net
  This might be obvious to everyone else, but it did cause some confussion when I first started working with SSIs.

You can insert a $ into a string by escaping it with a \ If you need to check the contents of a string (say $foo) matches the string '$bar' ('$' + 'b' + 'a' + 'r') you can with:

 
<!--#if expr="$foo = \$bar" -->
  And finally if you need to concatenate two strings where there might be an ambiguous result, you can acomplish this by enclosing the variables to be de-reference with {} Assume that $foo is equal to "the quick" and $bar is equal to "brown fox". The can be safely oncatenated by...  
<!--#set "myvar" value="${foo}some other text${bar}" -->
 

XBitHack

The XBitHack provides an alternative method of enabling SSIs on Unix servers. This doesn't seem to work with 1.3b6 on NT. If you know differently, please let me know. The XBitHack causes Apache to check the execute priviledges for a particular html file. If they are set, Apache will parse the file looking for SSI directives.

XBiitHack has there settings.

  • off The execute bit is not checked, so no SSIs
  • on Any file with +x premissions will be treated as a server-parsed (SSI) document
  • full Like all but the group-execute bit ( +gx ) is tested. If set, then the last modified time of the file is returned as "Last-modified". If not set, the no "Last-modified" date is returned.
XBitHack

SSI Gotachas!

Trailing Slash .../

Watch out for a trailing slash /. If you add a trailing slash to the url for a page, you will break SSI. i.e. The reference for this page is:
 

http://jlk.net/apache/colophon_ssi.shtml
  but if you add a trailing slash  

http://jlk.net/apache/colophon_ssi.shtml/
  all hell will break loose with SSIs. Just follow the link above with the trailing slash to see what is looks like. This link will be back to the original document.

Comment terminator

You should put a space between the SSI token and the comment terminator. i.e.
 
<!--#echo var="HTTP_HOST" -->
                         ^
 

Properly formatted SSI commands

Don't forget the #
 
<!--echo var="HTTP_HOST" -->
should be
<!--#echo var="HTTP_HOST" -->
    ^
  and to put a space between the start of
comment <-- and the #
 
<!-- #echo var="HTTP_HOST" -->
should be
<!--#echo var="HTTP_HOST" -->
    ^
  Either of these mistakes will not produce an error but you will see the comment if you view the source of you page with your browser.

Remember: if your SSI commands are correctly formatted and you server is correctly configured for SSIs, you will never, never, see the SSI string in the "View Source" output of your browser.

index.shtml ???

Having problems with index.shtml not working? All you get is a listing of the files in the directory! Add the following to your srm.comf
 
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index.  Separate multiple entries with spaces.

DirectoryIndex index.html index.shtml
   


XSSI eXtended SSIs   RTFM Index
Tell us what you think!
Copyright © 2006 Open Source Migrations ltd. All Rights Reserved.
Apache RTFM last updated Saturday October 21 2006