SSI (Server Side Includes) and SHTML Setup

By using SSI, you can utilize dynamic features for your web site.  For example, by placing the following code...

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

...inside your HTML and naming your HTML file with the extension .shtml, when the .shtml file is called via a browser, the server will scan (parse) the HTML code for special commands.  The command above generated the following date when you "called" for this web page via your browser...

Friday, 20-Oct-2017 20:08:30 CDT

We can easily change how the date looks such as...

<!--#config timefmt="%A, %B %d %Y" --> <!--#echo var="DATE_LOCAL" -->

...results in...

Friday, October 20 2017

So what commands are available regarding the date?  Here they are...

Display Full Display Abbreviated
Code Results Example Code Results Example
%B Month October %b Month Oct
%A Weekday  Friday %a Weekday Fri
%Y Year 2017 %y Year 17
%D Date 10/20/17 %d Day of the Month 20
Other Customizations
%H Current Hour
20 %I Current Hour
%M Current Minutes
08 %S Current Seconds
%p AM or PM PM %Z Time Zone CDT
%m Month (1-12) 10      
Time Saving Commands
%R Time
(24 hours)
Displayed as...
20:08 %r Time
(12 hours)
Displayed as...
08:08:30 PM
%T Time
(24 hours)
Displayed as...


Date and Time Examples...
<!--#config timefmt="%A %B %d %Y" --> <!--#echo var="DATE_LOCAL" --> Friday October 20 2017
<!--#config timefmt="%I %p" --> <!--#echo var="DATE_LOCAL" --> 08 PM
<!--#config timefmt="%B %d" --> <!--#echo var="DATE_LOCAL" --> October 20


Additional SSI Commands
Web Page Related...
<!--#echo var="HTTP_REFERER" --> The page that brought you here was...
<!--#echo var="REMOTE_ADDR" --> Your IP address is...
<!--#echo var="DOCUMENT_NAME" --> The name of the web page you are currently viewing is...
<!--#fsize file="ssi_and_shtml.shtml" --> The size of the web page you are currently viewing is...
<!--#flastmod file="ssi_and_shtml.shtml" --> The page you are currently viewing was last modified on...
  Tuesday, 24-Jan-2006 10:16:26 CST
Date Related...
<!--#echo var="DATE_LOCAL" --> Current Date and Time...
  Friday, 20-Oct-2017 20:08:30 CDT
<!--#echo var="DATE_GMT" --> Current GMT Date and Time...
  Saturday, 21-Oct-2017 01:08:30 GMT
<!--#include file="folder/name.txt" --> You can include a text file or some other file to be displayed.  Friday, 20-Oct-2017 20:08:30 CDT

Running a CGI or PL program from .shtml

If you call or run a CGI or PL program from an HTML document in a statement such as...

<!--#exec cgi="/cgi-bin/counter/counter.cgi" -->

...make sure you name the HTML file with the extension ".shtml" or it will not run the requested CGI program.

Because the server scans the SHTML file for special codes, this scan will result in two side effects.  1. A pause in display while the server scans the HTML file and performs any requested actions it finds embedded within the HTML, and 2. More server resources are naturally required to parse a .shtml page.  Keep this in mind as to not overuse .shtml pages on a busy web site.

Common Questions About SSI (SHTML)

PROBLEM:  When I view the .shtml page in the browser, and then view the HTML source code, the SSI command is still there and the expected results aren't displayed.

WHAT IS HAPPENING:  The server does not recognize the SSI command.

SOLUTION:  For all SSI commands, make sure there is ONE SPACE before the closing symbol --> as follows...
<!--#exec cgi="/cgi-bin/counter/counter.cgi" -->

PROBLEM:  The page shows the following...
[an error occurred while processing this directive]

WHAT IS HAPPENING:  The server recognizes the SSI command, however, there is an error in the SSI command and the server doesn't know what to do.

SOLUTION:  Make sure the path and filename in the SSI command is correct.

PROBLEM:  When I view the .shtml page in the browser, and then view the HTML source code, the SSI is no longer there, but the are no results displayed in its place.

WHAT IS HAPPENING:  The server has recognized the SSI command and has attempted to run the CGI or PL program.  However, there is either an error in the CGI program, or no output is defined in the CGI program.



Please note that scripts can enter infinite loops and cause problems for any server.  Please edit scripts with care!

For additional assistance visit our CGI-bin Applications Page.

[Manual Index]


Copyright 2000-2006 All Rights Reserved. Terms and Conditions of Use and Privacy Policy. - Your Success Is Our Success