Skip to content

Instantly share code, notes, and snippets.

@faridprogrammer
Created September 4, 2019 11:04
Show Gist options
  • Save faridprogrammer/a1ad5572bb3a0a71806fe778dfad46ce to your computer and use it in GitHub Desktop.
Save faridprogrammer/a1ad5572bb3a0a71806fe778dfad46ce to your computer and use it in GitHub Desktop.
Force SSL without www
<rewrite>
<rules>
<rule name="Force non-WWW" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}/{R:1}" appendQueryString="true" />
</rule>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment