SSI - Server Side Includes SEARCH
Server Side Includes (SSI)
SSI is an old but still effective way to simplify certain web page tasks. Essentially, with SSIs you can "include" pages or scripts in the text of a web page without having to write it out every time. A perfect example is a page footer, like the one at the bottom of this page - that can be referenced in a single line, and then when we want to make changes we can change just the single footer file rather than the html on every page that uses the footer. SSI can include information like current date, the file's last modification date, and the size or last modification of other files.

Every hosting account supports Server Side Includes automatically!   IMPORTANT: in order for SSIs 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!