<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="RemoveHTMLExtension" stopProcessing="true">
                    <match url="^([^\.]+)$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{R:1}.html" />
                </rule>
                <rule name="RedirectHTMLExtension" stopProcessing="true">
                    <match url="^(.*)\.html$" />
                    <conditions>
                        <add input="{THE_REQUEST}" pattern="^[A-Z]{3,}\s/+(.*)\.html[\?\s]" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" />
                    </conditions>
                    <action type="Redirect" url="{R:1}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>