Processing .html files as PHP

In the interest of having cleaner URLs (or simply to maintain existing links) it is often desirable for webpages to end in a .html extension even if they need to be processed as PHP. On Apache servers this is very straight forwards and you just add the following lines of code to your .htaccess file

AddType x-mapp-php5 .php .htm .html

On Windows servers this is slightly more complicated (as are most things). You need the following code in your web.config file and the value for the scriptProcessor is based on the install location of your php-cgi.exe file. Finding the location of this file can often be teased out by looking at the results from the phpinfo(); command.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
		<handlers>
            <add name="PHP_via_FastCG1" path="*.htm" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP5.5\php-cgi.exe" resourceType="Either" />
            <add name="PHP_via_FastCG2" path="*.html" verb="*" modules="FastCgiModule" scriptProcessor="C:\PHP5.5\php-cgi.exe" resourceType="Either" />
        </handlers>
    </system.webServer>
</configuration>