Just a short, simple blog for Bob to share his thoughts.
29 October 1998 • by Bob • IIS
A few years ago I put together a bunch of notes about using Server-Side-Include (SSI) files with IIS 4. These notes eventually became Microsoft KB article Q203064, and I updated that information a couple of years later to incorporate IIS 5. This information is no longer available from Microsoft's support website, so I thought that it would make a good blog post.
This article details some features that are available in the Microsoft implementation of Server-Side Include (SSI) files for Internet Information Server (IIS) and provides general syntax and examples for SSI directives.
SSI files are most commonly used with IIS to allow content authors to include the contents of one file inside another file, allowing the easy creation of script libraries or page headers and footers.
SSI files, like Active Server Pages (ASP) and Internet Data Connector (IDC) files, are script-mapped by file extension to a preprocessor dynamic-link library (DLL). In the case of SSI, the handler is Ssiinc.dll. SSI files are usually named with .stm file extensions, although extensions of .shtm and .shtml are also supported.
SSI is employed by the use of special preprocessing directives in SSI documents. These directives are parsed by the SSI DLL and processed. All directives are contained in HTML comment tokens and take the following general form:
<!--#<DIRECTIVE> [<ADDITIONAL DATA>]-->
<!-- #CONFIG <ERRMSG/TIMEFMT/SIZEFMT>="<format>" -->
<html> <body> <!-- #CONFIG TIMEFMT="%m/%d/%y" --> <p>Today's Date = <!--#ECHO VAR = "DATE_LOCAL" --></p> <!-- #CONFIG TIMEFMT="%A, %B %d, %Y" --> <p>Today's Date = <!--#ECHO VAR = "DATE_LOCAL" --></p> </body> </html>
<!--#ECHO VAR = "<CGI_VARIABLE_NAME>"-->
<html> <body> <p>Server Name = <!--#ECHO VAR = "SERVER_NAME"--></p> <p>Date = <!--#ECHO VAR = "DATE_LOCAL" --></p> <p>Page URL = <!--#ECHO VAR = "URL" --></p> </body> </html>
<!-- #EXEC <CGI/CMD>="<command>" -->
233969 SSIEnableCmdDirective is set to FALSE by default
<html> <body> <p>Root Directory of C:</p> <pre><!--#EXEC CMD="cmd /c dir c:\ /b"--></pre> </body> </html>
<!--#FLASTMOD <FILE/VIRTUAL> = "filename.ext"-->
<html> <body> <!-- #CONFIG TIMEFMT="%m/%d/%y" --> <p>Modified Date = <!--#FLASTMOD FILE="filename.ext"--></p> <!-- #CONFIG TIMEFMT="%B %d, %Y" --> <p>Modified Date = <!--#FLASTMOD FILE="filename.ext"--></p> </body> </html>
<!--#FSIZE <FILE/VIRTUAL> = "filename.ext"-->
<html> <body> <!-- #CONFIG SIZEFMT="BYTES" --> <p>File Size = <!--#FSIZE FILE="filename.ext"--> bytes</p> <!-- #CONFIG SIZEFMT="ABBREV" --> <p>File Size = <!--#FSIZE FILE="filename.ext"--> KB</p> </body> </html>
<!--#INCLUDE <FILE/VIRTUAL> = "filename.ext"-->
<html> <body> <!--#INCLUDE FILE = "header.inc"--> <p>Hello World!</p> <!--#INCLUDE VIRTUAL = "/includes/footer.inc"--> </body> </html>
<!--#include file="myfile.txt"-->
<!--#include virtual="/scripts/myfile.txt"-->
For additional information on using SSI with IIS, click the following article numbers to view the articles in the Microsoft Knowledge Base: