Search  |  Contact  |  Site Map  |  Print
FastVirtual Web Hosting & Internet Services Customer Care  
Web Hosting  |  Domain Names  |  Web Site Builder  |  Internet Access  |  Support Center  |  About FastVirtual

Server Side Includes

Include dynamic components in your web
pages, or assemble pages on-the-fly.

Server Side Includes (SSI) allow you to include dynamic components in your web pages. You can use SSI to assemble web pages from other HTML documents, or output from CGI scripts, enabling you to dynamically construct pages whenever they are loaded. By including SSI-generated headers, footers and other variables in your web pages, you can make changes to your entire web site by editing only a few files.

Note: There are known incompatibilities with Microsoft FrontPage and .shtml files. FrontPage has it's own way of including variables, called "bots", and we recommend that FrontPage users use this method instead of SSI.

SSI Page Requirements

To instruct the server to look for SSI commands, your page should end in an ".shtml" extension. SSI commands will not be recognized if the page has an ".html" extension.

Including HTML Files and CGI Script Output

You can include HTML files, text files, and CGI script output in your .shtml documents as follows:

<!--#include virtual="/myhtmlfile.html" -->
<!--#include virtual="/cgi-bin/mycgiscript.cgi" -->

Global SSI Variables

The following global SSI variables can also be used in your .shtml documents. These should be included as follows:

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

Variable Description
HTTP_REFERER The page from which the visitor came
HTTP_USER_AGENT The visitor's browser software
SERVER_SOFTWARE The version of the web server
SERVER_NAME Your server name
REMOTE_ADDR The remote IP address of the visitor
REMOTE_USER The username (in a restricted area)
QUERY_STRING Any data following a '?' in the URL
DOCUMENT_NAME The name of the current file
DATE_LOCAL The current date (PST)
DATE_GMT The current date (GMT)
LAST_MODIFIED Last modified date of the current file

For details of all available SSI variables, simply create an ,shtml document with the following command:

<!--#printenv -->

Upload the file to your domain, and load the page in your web browser.

Displaying the File Size

You can display the file size of your .shtml documents in bytes as follows:

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

You can also display the file size in Kb or MB as follows:

<!--#config sizefmt="abbrev" -->
<!--#fsize -->

Displaying Time/Date Stamps

You can display time/date stamps in your .shtml documents. You first need to specify the time/date format as follows:

<!--#config timefmt="%I:%M:%S%p" -->

You can then use this with the "echo" command to display the current date as follows:

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

You can also display the date the document was last modified as follows:

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

The following parameters can be used to format time/date stamps:

Variable Description
%c Time and date
%R Time (hh:mm)
%T Time (hh:mm:ss)
%r Time (hh:mm:ss AM)
%H Hour (24-hour clock, 00-23)
%k Hour (24-hour clock, 0-23)
%I Hour (12-hour clock, 01-12)
%l Hour (12-hour clock, 1-12)
%M Minutes (00-59)
%S Seconds (00-59)
%p AM or PM
%s Number of seconds since January 1, 1970
%Z Time zone
%D Date
%a Abbreviated day of week name (Mon, Tue, etc.)
%A Full day of week name (Monday, Tuesday, etc.)
%w Day of week number (0-6), 0=Sunday
%b Abbreviated name of month (Jan, Feb, etc.)
%B Full name of month (January, February, ...)
%m Month number (01-12)
%d Day of month (01-31)
%e Day of month (1-31)
%y 2-digit year
%Y 4-digit year
%C Century
%j Day of year (001-366)
%W Week of year (00-53) starting Monday

Specifying Variables

You can specify variables to load in your .shtml documents as follows:

<!--#set var="VARIABLE_NAME" value="VARIABLE_VALUE" -->

You can then use this with the "echo" command to display the variable as follows:

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

Parsing SSI in Other File Types

Files that are intended to parse SSI instructions should end in .shtml. FastVirtual does not support parsing SSI commands in other file types.

Adding the following line to your .htaccess file may work:

AddType text/x-server-parsed-html .shtml .html .htm etc.

However, this method not efficient and may degrade performance of the file types you specify. FastVirtual does not provide support for problems that may result from this configuration change.

Using Extended Server Side Includes (XSSI)

FastVirtual's web servers use Apache, which supports XSSI. For further information, please see the Apache SSI Documentation.

Web Hosting  |  Domain Names  |  Web Site Builder  |  Internet Access  |  Support Center  |  About FastVirtual  |  Articles  |  Search  |  Contact  |  Site Map
Top of Page FastVirtual, Inc. All Rights Reserved.  Privacy Policy  |  Web Site Usage Terms  |  General Service Agreement