<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="newmexicomastersswimming">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain1\.org$" />
</conditions>
<action type="Redirect" url="https://domain1.org/{R:1}" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{REQUEST_URI}" pattern="/sitecore/api/.*" negate="true" />
<add input="{REQUEST_URI}" pattern="/ahp.aspx" negate="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Lets break it down
Single URL
This rule will redirect a single domain from anything www.domain1.org
to https://domain1.org. And the nice part of this is that it does not require a www.domain.org SSL cert. Just domain.org SSL cert is needed. You can add as many of these rules as you want.
<rule name="domain1">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain1\.org$" />
</conditions>
<action type="Redirect" url="https://domain1.org/{R:1}" />
</rule>
Catch all
This rile is the catch all rule that will take ANY HTTP request and flip it to HTTPS. I have also included some exclusions /sitecore/api/.*
and /ahp.aspx
in case you have a requirement to not force a URL to redirect. An issue I had with FXM and CORS.
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{REQUEST_URI}" pattern="/sitecore/api/.*" negate="true" />
<add input="{REQUEST_URI}" pattern="/ahp.aspx" negate="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>