I'm trying to add a redirection rule in web.config to only serve my webpage in HTTPS and no HTTP at all; so far I've used this ruleset (together with my 404 redirect):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
<httpErrors errorMode="Custom" existingResponse="Auto">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="index.php" responseMode="Redirect" />
</httpErrors>
</system.webServer>
</configuration>
However, this leads to ERR_TOO_MANY_REDIRECTS; what is wrong with this web.config to cause this? It seems to work for other users.
I have already tried suggestions in these posts; Redirect loop when forcing HTTPS, URL Rewrite causing redirect loop, this blog and this blog.