I have an MVC4 application running on HTTP and HTTPS. Bsaically I want to ensure that all non-www requests direct to the www. version regardless of what protocol they are using. I am struggling to define this in URL Rewrite as my web.config rules is failing to load the site when adding the below code to the <server.webserver>
node
<rewrite>
<rules>
<rule name="Redirect to www" stopProcessing="true">
<match url="(.*)" />
<conditions trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^domain.com$" />
</conditions>
<action type="Redirect"
url="{MapProtocol:{HTTPS}}://www.domain.com/{R:1}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="MapProtocol">
<add key="on" value="https" />
<add key="off" value="http" />
</rewriteMap>
</rewriteMaps>
</rewrite>
Any advice on how to create the redirect in IIS would be great