PRIMUS Home Page PRIMUS Support
USING SERVER-SIDE INCLUDES





ACCOUNT MANAGER

--

--

 

What They Are

Normally, web documents are sent to the browser of the person who requests them (the client) as regular text files. HTML tags in the document are parsed by the browser of the client to format the page.

In order to include dynamic content in the documents that can change each time the document is served, a web server can be told to parse, or look for and execute, commands that are present in the document before it is sent to the client's browser.

Some of the things that these commands to the server can do are:

  • print the current date and time or the date and time that the file was last modified
  • include the contents of a particular file
  • execute a cgi script

Using Server Side Includes at PRIMUS

PRIMUS's web servers running the Apache web server are configured to parse any documents that are named with the file extension .shtml.

Commands to the server always conform to the following format:

 <!--#command attribute=value--> 

Below are some useful commands that can be included within .shtml documents.

include

The include command inserts a text file into the parsed file. This can be a CGI script if the CGI script outputs HTML. It can also just be another HTML document. The permissions on the included file must be set to allow access to the user requesting it.

The include command can be used in one of two ways:
 <!--#include virtual="/path/to/file/to/be/included.html"--> 
or <!--#include file="relative/path/from/current/directory"--> 

echo

The echo command prints data from a specific variable. For example, you can print the date at the time (local time zone) that the document is loaded. The command looks like this:

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

(var stands for variable)

and will return the following output:

Saturday, 05-Jul-2008 14:35:26 EDT

Other values you can use for the var attribute include:

  • DATE_GMT - same as DATE_LOCAL but in Greenwich Mean Time
  • DOCUMENT_NAME - name of current document
  • DOCUMENT_URI - virtual path to current document
  • LAST_MODIFIED - date that current file was last modified

as well as any variables in the CGI Variables set.

fsize

The fsize command prints the size of a given file. The attributes accepted for fsize are the same as those used for the include command. For example, to print the file size of this document, I would use the following command:
 <!--#fsize 
file="ssi.html"--> 

the output would look like this:

5k

flastmod

flastmod prints the date that a given file was last modified. The attributes are the same as those for include and fsize. To see when this document was last modified, you would use a command like this:

 <!--#flastmod file="ssi.html"--> 

to get the following output:

Thursday, 31-Oct-2002 13:55:06 EST

exec

For security reasons, PRIMUS does not allow the exec command to be used in server parsed HTML documents. If you would like to use SSI to include a CGI Script, the include command will work just fine. Just include the path to the CGI Script as if it were any other document.



Back to Shared Hosting Support

2004 PRIMUS All Rights Reserved
PRIMUS Home Page PRIMUS Support