|
Using SSI (Server Side Includes)
Server Side Includes - SSI can include information like current date, the file's last modification date, and the size or
last modification of other files.
IMPORTANT : In order for Server Side Includes to work, your file must be named with the ".shtml" extension.
SSI can be used to output the last modification date of the file the user requested. This is done by using the
"echo" element and the LAST_MODIFIED variable. The command would be:
<!--#echo var="LAST_MODIFIED" -->
Other variables that can be output in this fashion include DATE_LOCAL (date in the local time zone, EST), DATE_GMT (date in
Greenwich Mean Time), DOCUMENT_NAME (the filename of the document), and DOCUMENT_URI (the URL path of the document).
Another common use of SSI is to include the output of a CGI script within your page. The SSI command to do so is:
<!--#exec cgi="/cgi-bin/included_script.cgi" -->
The most common use for SSI is probably including a file within your page. This could be used to have a common footer on every page, for
instance, while still being able to change it by altering a single file. Including a file via SSI is done with:
<!--#include virtual="/filename.html" -->
The value of the "virtual" attribute is derived from the URL needed to view the file under your domain name, minus the domain
name and "http://". For instance, if the file to be included is located at http://www.example.com/files/includes/first.txt, your call to include it in other files
under that domain would be:
<!--#include virtual="/files/includes/first.txt" -->
In some cases, you may want every .html file to be parsed for SSI. This can be done with the following command in your .htaccess file:
AddType text/x-server-parsed-html .html
Note: Please do not do this unless you genuinely intend to use SSI in all of your files. The unnecessary overhead of parsing the files
that do not actually use SSI will slow the server down and make your site less responsive (each file will take longer to download as the server must process every file).
Also, don't do this for .shtml files; it will make them stop working!
More info
You can find more info on SSI At Apache's Website. and at http://hoohoo.ncsa.uiuc.edu/docs/tutorials/includes.html
|