Does this not mean that there is a conditional? It checks if HTTPS is turned off, and only then a redirect will occur. If HTTPS is enabled, you should not redirect, otherwise you will end up with endless redirects.
If you always want the hostname to be www.domainname.com
, you should add this as an additional condition. For instance:.
<rule name="Force HTTPS and host name: www.domainname.com" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTPS}" negate="true" pattern="^ON$" /> <add input="{HTTP_HOST}" negate="true" pattern="^www\.domainname\.com$" /> </conditions> <action type="Redirect" url="https://www.domainname.com/{R:0}" appendQueryString="true" redirectType="Permanent" /> </rule>
If either HTTPS
not ON
or HTTP_HOST
not www.domainname.com
, it will be redirected. Only if both values ββare true will they not be redirected.
source share