Pages

Friday, August 12, 2011

web.config Index Redirect

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Imported Rule 1" stopProcessing="true">
                  <match url="^(.*)$" ignoreCase="false" />
                  <conditions>
                    <add input="{HTTP_HOST}" pattern="^testdomain\.com$" />
                  </conditions>
                  <action type="Redirect" redirectType="Permanent" url="http://www.testdomain.com/{R:1}" />
                </rule>  
                <rule name="CanonicalHostNameRule1" stopProcessing="true">
                    <match url="index\.htm(?:l)?" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="testdomain\.com$" />
                        </conditions>
                        <action type="Redirect" url="http://www.testdomain.com/" />
                </rule>

            </rules>
        </rewrite>
    </system.webServer>
</configuration>