I need to redirect non-www urls to www url for both http and https urls. I tried following rules in web.config.
<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" />
<rule name="Redirect to WWW https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="^domain.com$" />
</conditions>
<action type="Redirect" url="https://www.domain.com/{R:0}" redirectType="Permanent" />
It works perfectly for non-ssl url but in case of ssl it redirect from https://domain.com to http://www.domain.com
Please help me to correct my rules.