Redirect index.html and non www to www using web.config

I use a standard web.config file in my projects which are hosted on Windows servers. Now i need to redirects non www url to www with https and remove the index.html from the url.

            <rule name="Redirect to HTTP" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".*"></match>
                    <add input="{HTTP_HOST}" pattern="^$"></add>
                    <add input="{HTTPS}" pattern="off"></add>
                <action type="Redirect" url="{R:0}" redirectType="Permanent" appendQueryString="true"></action>
            <rule name="redirect index.html" stopProcessing="true">
                <match url="^(\w*/)?index\.html" />
                    <add input="{HTTP_HOST}" pattern="visasimple\.com$" />
                <action type="Redirect" url="{R:1}" />
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />

Leave a Reply