| If you wish to use server side includes in a web page, the file
name of that web page must have the .shtml extension(eg. index.shtml)
The 'SS' stands for Server-side and the 'I' stands for whatever
your consultant tells you. 'Includes' and 'interface' are both popular.
(SPML -- Server Parsed Markup Language -- is also used to refer
to the code you write. Really, you can learn the entire small command
set SSI provides before you learn the acronyms.) Basically, SSI
is a mechanism whereby you can have our server do something to your
HTML before sending it to the browser. SSI does some of the same
things CGI does. Some differences are that SSI doesn't handle forms
(at least, I haven't seen anyone bother trying) but CGI is much
more involved if you just want another file or the output of a program
included in your document. To have a document parsed for SSI directives,
give it the extension .shtml instead of .html. You
could also make it executable if changing the filename is too much
trouble. (chmod +x file.html) Note: To use an executable
.html file for SSI, you must include a .htaccess file in the directory
wherein the .html file resides. Include in the .htaccess file the
entry: AddType text/x-server-parsed-html .html . Formal documentation
is available from within
the Apache manual. The following example should show you what
sorts of things are possible:
<html>
<head><title>SHTML test</title></head>
<body>
<h1>#1</h1>
Your IP address is <!--#echo var="REMOTE_ADDR"-->.
<h1>#2</h1>
This document's filename is <!--#echo var="DOCUMENT_NAME"-->.
<h1>#3</h1>
The Universal Time Coordinate is <!--#exec cmd="/bin/date --utc"-->.
Running another program makes for an example, but note
that the current time is availible like so:
<!--#echo var="DATE_LOCAL"-->.
<h1>#4</h1>
Here I include a footnote.
<hr>
<!--#include virtual="foot.html"-->
</body>
</html>
|