SSI commands not working for shtml files in iis
The following code should show the port or server name wrong.
I always get both no matter what?
<!--#if expr="${SERVER_PORT} = 80" -->
<!--#echo var="SERVER_PORT"-->
<!--#else -->
<!--#echo var="SERVER_NAME"-->
<!--#endif -->
I haven't tried the following either:
<!--#if expr="${SERVER_PORT} = '80'" -->
<!--#if expr="${SERVER_PORT} = /80/" -->
How do I get this to work?
If you are using IIS 6 make sure server side use is allowed:
- Launching IIS MMC
- Expand the Tree and select the Extensions web service
- Make sure the server side has Allowed
If so, check if SSI Script Maps are allowed in the website properties:
- Launching IIS MMC
- Right click and properties on site
- Select the "Home Directory" tab
- Click "Configuration"
- Make sure the extensions are
.shtm, shtml and .stm
mapped toC:\WINDOWS\system32\inetsrv\ssinc.dll
and that the verbs are set toGET
andPOST
.
Updated:
IIS does not support the construct #if/#else/#endif
or #set
. The IIS 6.0 Server Side Include directives are described here:
Server Side IIS Directives (MSDN Library)
These are all the same goals as in IIS 5.1.
The directives you are trying to use are supported in Apache, although you should check your host / admin to make sure they are enabled. For more information see:
Apache Tutorial: Server Side Introduction Includes