Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use web.config to allow server-side includes in HTML files (IIS)

In IIS 7.5, is it possible to use web.config alone to enable SSI processing for files that have the .html extension? Specifically, I don't want to use the default SSI extension, .shtml.

Reason: I don't want to change the extensions. Doing so would lead to broken links in search engine results.

Also, my motivation for doing this in web.config is because this is a shared server.

like image 870
Trojan Avatar asked Jul 16 '13 22:07

Trojan


People also ask

How do I enable server side includes in IIS 10?

On the taskbar, click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then select Server Side Includes, and then click OK.

What are server side includes in IIS?

With SSI directives, you can include the contents of a file in a Web page, include information about a file, include server variables, or include the output from executables, such as Common Gateway Interface (CGI files) and Internet Server API (ISAPI) applications.

Which files are use mapped to Ssinc DLL?

stm, . shtm, and . shtml are mapped to the SSI interpreter (ssinc. dll).

What is SSI in Web technology?

Server-side includes (SSI) are a mechanism for employing the web server to perform tasks like displaying files as part of other files or displaying information like the URL of web pages or dates and times dynamically.


1 Answers

Presuming that your hoster has enabled SSI's and delegated Read/Write permissions for handler mappings then this should work:

<configuration>
    <system.webServer>
        <handlers>
            <add name="SSINC-html" 
                 path="*.html" 
                 verb="*" 
                 modules="ServerSideIncludeModule" 
                 resourceType="File" 
                 requireAccess="Script" />
        </handlers>
    </system.webServer>
</configuration>

Whilst we're on the topic, Robert McMurray (MSFT IIS staffer) has a fairly recent refresher blog post all about SSI's here:

http://blogs.iis.net/robert_mcmurray/archive/2010/12/28/iis-notes-on-server-side-includes-ssi-syntax-kb-203064-revisited.aspx

like image 190
Kev Avatar answered Sep 22 '22 12:09

Kev