I have this rewrite rule:
<system.webServer>
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domain\.no$" negate="true" />
</conditions>
<action type="Redirect" url="https://www.domain.no/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Which I suspect is kinda wrong, as it will only redirect from http://domain.no to https://WWW.domain.no when I set up site bindings for the non-canonical name. I wonder then, is it strictly necessary to set all four bindings for a web site with SSL, in order to redirect from non-canonical HTTP to canonical HTTPS?
ie. http://domain.no, http://www.domain.no and the canonical httpS://domain.no and httpS://www.domain.no. My DNS server has records for both names and the certificates are from LetsEncrypt.
As it turns out, the Certificate Binding (SSL Handshake) precedes the URL Rewrite 2.1 engine in the IIS pipeline. Hence my own answer, just to confirm that you do need to set up the four bindings for a site.