Microsoft KB Archive/203064

= IIS: Notes on Server-Side Includes (SSI) syntax =

Article ID: 203064

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Internet Information Services 5.0
 * Microsoft Internet Information Server 4.0

-



This article was previously published under Q203064



We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:

http://www.microsoft.com/technet/security/prodtech/IIS.mspx



SUMMARY
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.



MORE INFORMATION
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:

Supported Directives
The following directives are supported in the IIS implementation of SSI:  #config - Configures how variables and commands are displayed.   The general syntax for the #config directive is as follows:   The following is an example of a simple page that uses the #config directive:

Today's Date =

Today's Date =   #echo - Inserts the value of various Common Gateway Interface (CGI) system environment variables.   The general syntax for the #echo directive is as follows: </li>  The following is an example of a simple page that uses the #echo directive: Server Name = Date = Page URL = </li></ul> </li> #exec - Executes CGI or Internet Server API (ISAPI) command scripts and inserts output into an HTML document.   The general syntax for the #exec directive is as follows: </li> The CMD command for the #exec directive is disabled by default on IIS 5.0. For more information, see the following Microsoft Knowledge Base article:

233969 SSIEnableCmdDirective is set to FALSE by default

</li>  The following is an example of a simple page that uses the #exec directive: Root Directory of C:                        </li></ul> </li> #flastmod - Retrieves the last modification time of a specified file.   The general syntax for the #flastmod directive is as follows: </li>  The following is an example of a simple page that uses the #flastmod and #config directives:

Modified Date =

Modified Date = </li></ul> </li> #fsize - Retrieves the size of a specified file.   The general syntax for the #fsize directive is as follows: </li>  The following is an example of a simple page that uses the #fsize and #config directives:

File Size = bytes

File Size = KB                         </li></ul> </li> #include - Includes the contents of one specified file inside another.  <li> The general syntax for the #include directive is as follows: </li> <li> The following is an example of a simple page that uses the #include directive:

Hello World!

</li></ul> </li></ul>

More Information on File and Virtual Syntax
SSI directives that use file paths can reference files by using a file or virtual path. <ul> <li> The file element is used with files that are relative to the folder of the current document. The following example includes a file in the current folder: </li> <li> The virtual element represents paths that are relative to the base folder of the Web server. The following example includes a file in the /scripts virtual folder: </li></ul>

<div class="references_section">