IIS8 Redirect http/https and non WWW in one rule

13th February 2018
by InfiniteMonkeys

Simple IIS rewrite to redirect all non-SSL and non-www traffic in a single URL rule, just place in the web.config:

<rule name=”Force WWW and SSL” enabled=”true” stopProcessing=”true”>
<match url=”(.*)” />
<conditions logicalGrouping=”MatchAny”>
<add input=”{HTTP_HOST}” pattern=”^[^www]” />
<add input=”{HTTPS}” pattern=”off” />
<action type=”Redirect” url=”https://FQDN/{R:1}” appendQueryString=”true” redirectType=”Permanent” />

** Note you need the module installed first, reload IIS after installation.