.netiisssishtml

SSI commands not working is for shtml files in iis


The following code should show either the port or server name not both.

I always get both no matter what ?

<!--#if expr="${SERVER_PORT} = 80" -->
<!--#echo var="SERVER_PORT"-->
<!--#else -->
<!--#echo var="SERVER_NAME"-->
<!--#endif -->

I have also tried the following with no joy either:

<!--#if expr="${SERVER_PORT} = '80'" -->
<!--#if expr="${SERVER_PORT} = /80/" -->

How do I get this working?


Solution

  • If you're using IIS 6 check that Server Side Includes are permitted:

    1. Launch IIS MMC
    2. Expand Tree and select Web Service Extensions
    3. Check that Server Side Includes are Allowed

    If they are, then check that the SSI Script Maps are enabled in the web site properties:

    1. Launch IIS MMC
    2. Right Click and Properties on Site
    3. Select Home Directory Tab
    4. Click Configuration
    5. Verify that the extensions .shtm, shtml and .stm are mapped to C:\WINDOWS\system32\inetsrv\ssinc.dll and that the verbs are set to GET and POST.

    Updated:

    IIS doesn't support the #if/#else/#endif construct or #set. IIS 6.0's Server Side Include directives are documented here:

    IIS Server-Side Include Directives (MSDN Library)

    These are for all intents and purposes the same as those used in IIS 5.1.

    The directives you're trying to use are supported on Apache, though your should check with your hoster/admin to make sure they're enabled. For more info see:

    Apache Tutorial: Introduction to Server Side Includes