Using Server Side Includes (SSI)
General information
Server Side Includes (SSI) are instructions that are placed
in Web pages and evaluated on the server while the pages are
being served. They allow you to include other files, such
as header and footer snippets, or to show the current date
and time or last-modified date of a file.
Using SSIs
In order for SSI to work, the file name of your Web page needs
to have the extension .html (e.g. index.html, resume.html).
Make sure to include the SSI directives in the HTML of your
Web page. To do that in Dreamweaver and Frontpage, you need
to switch to Code under the View menu.
Examples:
|
|
| Today's date/time |
Current date/time:
<!--#echo var="DATE_LOCAL" -->
|
Current date/time:
04/25/02 08:02 |
| Today's date |
<!--#config timefmt="%A, %B %e, %Y" -->
Today is:
<!--#echo var="DATE_LOCAL" -->
|
Today is: Thursday,
April 25, 2002 |
| Modification
date of a file |
This document last modified:
<!--#echo var="LAST_MODIFIED" -->
|
This document
last modified: Thursday, 25-Apr-2002 08:10:34 EDT |
| Modification
date of a file |
<!--#config timefmt="%B %e, %Y" -->
last modified:
<!--#echo var="LAST_MODIFIED" -->
|
last modified:
April 25, 2002 |
| Modification
date of a file |
<!--#config timefmt="%a, %B %e, %Y" -->
last change:
<!--#echo var="LAST_MODIFIED" -->
|
last change:
Thu, April 25, 2002 |
| Modification
date of a file |
<!--#config timefmt="%A, %D, %H:%M" -->
last modified:
<!--#echo var="LAST_MODIFIED" -->
|
last modified:
Thursday, 04/25/02, 08:24 |
| Include a footer
snippet |
<!--#include virtual="footer.html" -->
|
This is the
content of the Web page "footer.html" |
| Include a header
snippet contained in a sub-folder |
<!--#include virtual="includes/header.html" -->
|
This is the
content of the Web page "header.html" in
the folder "includes" |
| Include a header
snippet contained in the parent folder |
<!--#include virtual="../header.html" -->
|
This is the
content of the Web page "header.html" in
the parent folder |
For information about more advanced SSI instructions such
as variables and conditionals, please refer to the Apache
Tutorial: Introduction to Server Side Includes Web page.
(http://httpd.apache.org/docs/howto/ssi.html)
Note: For security reasons the
#exec directive is not supported.
|