DOCUMENT:Q203064 06-SEP-2001 [iis] TITLE :IIS: Notes on Server-Side Includes (SSI) Syntax PRODUCT :Internet Information Server PROD/VER::4.0,5.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Internet Information Services version 5.0 - Microsoft Internet Information Server 4.0 ------------------------------------------------------------------------------- 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: - The following is an example of a simple page that uses the #echo directive:

Server Name =

Date =

Page URL =

- #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: - 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: Q233969 SSIEnableCmdDirective Is Set to FALSE by Default - The following is an example of a simple page that uses the #exec directive:

Root Directory of C:

- #flastmod - Retrieves the last modification time of a specified file. - The general syntax for the #flastmod directive is as follows: - The following is an example of a simple page that uses the #flastmod and #config directives:

Modified Date =

Modified Date =

- #fsize - Retrieves the size of a specified file. - The general syntax for the #fsize directive is as follows: - The following is an example of a simple page that uses the #fsize and #config directives:

File Size = bytes

File Size = KB

- #include - Includes the contents of one specified file inside another. - The general syntax for the #include directive is as follows: - The following is an example of a simple page that uses the #include directive:

Hello World!

More Information on File and Virtual Syntax: SSI directives that use file paths can reference files by using a file or virtual path. - 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: - 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: REFERENCES ========== For additional information on using SSI with IIS, click the article numbers below to view the articles in the Microsoft Knowledge Base: Q169996 To Run an ISAPI DLL with #exec, Use the CGI Statement Q166491 Secure Batch Files Return Access Denied Error Message Q195291 How to Disable #exec in Server-Side Include files Additional query words: iis ssi ====================================================================== Keywords : Technology : kbiisSearch kbiis500 kbiis400 Version : :4.0,5.0 Issue type : kbinfo ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.