|Your Daily Source for Apache News and Information|
|Breaking News||Preferences||Contribute||Triggers||Link Us||Search||About|
This is the second of a three-article series on SSI. In the first article, we talked about how to enable SSI on your server and passed on some very basic examples. In this article, there will be more examples, and we'll talk about some somewhat more involved things that you might want to do with SSI. In the final article, we'll talk about the more advanced features of Apache SSI, including conditional statements.
In the last article, we mentioned that you could use SSI to inform the user when the document was most recently modified. However, the actual method for doing that was left somewhat in question. The following code, placed in your HTML document, will put such a time stamp on your page. Of course, you will have to have SSI correctly enabled, as discussed in the last article.
<!--#config timefmt="%A %B %d, %Y" --> This file last modified <!--#flastmod file="ssi.shtml" -->
Of course, you will need to replace the
<!--#config timefmt="%D" --> This file last modified <!--#echo var="LAST_MODIFIED" -->
For more details on the
If you are managing any site that is more than a few pages, you may find that making changes to all those pages can be a real pain, particularly if you are trying to maintain some kind of standard look across all those pages.
Using an include file for a header and/or a footer can reduce the burden of these updates. You just have to make one footer file, and then include it into each page with the
<!--#include virtual="/footer.html" -->
I'll frequently combine the last two things, putting a
In addition to being able to
Usually, when something goes wrong with your SSI directive, you get the message
[an error occurred while processing this directive]
If you want to change that message to something else, you can do so with the
<!--#config errmsg="[It appears that you don't know how to use SSI]" -->
Hopefully, end users will never see this message, because you will have resolved all the problems with your SSI directives before your site goes live. (Right?)
And you can
I expect that I'll have an article some time in the coming months about using SSI with small CGI programs. For now, here's something else that you can do with the
<pre> <!--#exec cmd="ls" --> </pre>
or, on Windows
<pre> <!--#exec cmd="dir" --> </pre>
You might notice some strange formatting with this directive on Windows, because the output from
Note that this feature is exceedingly dangerous, as it will execute whatever code happens to be embedded in the
In the next column, I'll talk about some of the more advanced features of SSI, in particular, the flow-control feature (conditional statements) and using variables.
Rich Bowen is the Director of Web Application Development at The Creative Group and the author of Apache Server Unleashed.
|About Triggers||Media Kit||Security||Triggers||Login|
All times are recorded in UTC.
Linux is a trademark of Linus Torvalds.
Powered by Linux 2.4, Apache 1.3, and PHP 4