Some Web servers allow the inclusion of some simple items such as the current time and when a file was last modified -- without the need for JavaScript, Java, Perl, ASP, JSP, or PHP
Server Side Includes (SSI) can be used for such simple items as well as to make a simple visitor counter
Many Web servers do NOT allow Server Side Includes because of security and/or time concerns. Make sure that your Web server does allow them before spending a lot of time making Web pages with SSIs. PUCC Web servers (icdweb, mentor, expert) DO allow SSIs.
Most servers that do allow SSIs look for them by default in files with a .shtml suffix and send those parsed files to the browser indicating that they are the same as .html files. In this arrangement, no time is wasted looking for SSIs in regular .html files -- only in .shtml files.
If you want to use any other suffix for SSI files, create in your www
folder (or some sub-folder) an .htaccess file that includes a line
like...
Here are some of the most useful commands and attributes:
Echo prints the value of one of the variables below:
flastmod prints the last modification date of the specified file.
Include will insert the text of a document into the parsed document. "Location" is the same as a relative URL.
exec cgi executes a given shell CGI script. (Sometimes echo, flastmod, and include are all enabled, BUT exec is not!)
First, notice that this Web page is named servexamp.shtml. The .shtml
extension is important or none of the SSIs will work. The file looks
like this:
REMOTE_ADDR is
DATE_LOCAL is
HTTP_USER_AGENT is
This file was last modified
You are visitor number
to this Website.
Server Side Include Examples
REMOTE_HOST is
Next, notice the "flastmod" directive to report when this file (it could be any file in this folder) was last modified.
The "exec cgi" directive runs a Perl script named count.cgi in the
same folder which looks like this:
Finally, notice the "include file" directive to grab another file info.txt and to include its contents as if they appeared in servexamp.shtml at that point.