SSI and SHTML

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...

Tuesday, 03-Dec-2024 10:49:59 CST

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

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

...results in...

Tuesday, December 03 2024

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

Display Full Display Abbreviated
Code Results Example Code Results Example
%B Month December %b Month Dec
%A Weekday  Tuesday %a Weekday Tue
%Y Year 2024 %y Year 24
%D Date 12/03/24 %d Day of the Month 03
Other Customizations
%H Current Hour
(1-24)
10 %I Current Hour
(1-12)
10
%M Current Minutes
(0-60)
49 %S Current Seconds
(0-60)
59
%p AM or PM AM %Z Time Zone CST
%m Month (1-12) 12      
Time Saving Commands
%R Time
(24 hours)
Displayed as...
(%H:%M)
10:49 %r Time
(12 hours)
Displayed as...
%I:%M:%S:%p
10:49:59 AM
%T Time
(24 hours)
Displayed as...
(%H:%M:%S)
10:49:59      

 

Date and Time Examples...
<!--#config timefmt="%A %B %d %Y" --> <!--#echo var="DATE_LOCAL" --> Tuesday December 03 2024
<!--#config timefmt="%I %p" --> <!--#echo var="DATE_LOCAL" --> 10 AM
<!--#config timefmt="%B %d" --> <!--#echo var="DATE_LOCAL" --> December 03

 

Additional SSI Commands
Web Page Related...
<!--#echo var="HTTP_REFERER" --> The page that brought you here was...
  (none)
<!--#echo var="REMOTE_ADDR" --> Your IP address is...
  3.12.154.133
<!--#echo var="DOCUMENT_NAME" --> The name of the web page you are currently viewing is...
  ssi_and_shtml.shtml
<!--#fsize file="ssi_and_shtml.shtml" --> The size of the web page you are currently viewing is...
   30K
<!--#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...
  Tuesday, 03-Dec-2024 10:49:59 CST
<!--#echo var="DATE_GMT" --> Current GMT Date and Time...
  Tuesday, 03-Dec-2024 16:49:59 GMT
Miscellaneous...
<!--#include file="folder/name.txt" --> You can include a text file or some other file to be displayed.  Tuesday, 03-Dec-2024 10:49:59 CST

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.

SOLUTION:

 

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 ActiveWebHost.com. All Rights Reserved. Terms and Conditions of Use and Privacy Policy. ActiveWebHost.com - Your Success Is Our Success