IIS Rewrite Rules (force www to non-www and http to https)

  • Redirect www site to non-www. eg. I use the rule below for my own website. If user browses to https://www.indexedmind.com, redirect them to https://indexedmind.com
    <rule name=”Redirect WWW to non-WWW” stopProcessing=”true”>
    <match url=”(.*)” />
    <add input=”{HTTP_HOST}” pattern=”^indexedmind\.com$” negate=”true” />
    <action type=”Redirect” url=”https://indexedmind.com/{R:1}” />
  • Redirect http request to https. eg. if user browses to http://indexedmind.com, force them to go to https://indexedmind.com
    <rule name=”Redirect to HTTPS” stopProcessing=”true”>
    <match url=”(.*)”/>
    <add input=”{HTTPS}” pattern=”^OFF$”/>
    <action type=”Redirect” url=”https://{HTTP_HOST}{REQUEST_URI}” redirectType=”SeeOther”/>