I am trying to enable HTTPS on a website on IIS. I want to redirect the user from http to https.
I have updated the rule accordingly in web.config to
<rewrite>
<rules>
<rule name="Redirect to HTTPs" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
I am able to convert the request to https but then it keeps redirecting to the same url with https. The problem is that the rule apparently keeps redirecting all urls including to https and then the browser in the network tab keeps lots of 301 and eventually throws
This webpage has a redirect loop
ERR_TOO_MANY_REDIRECTS
Please help me out here if someone has tackled a similar situation. I can provide more information if necessary.
Thank you
Try the following rewrite rule. This will work for websites served by single IIS server. Load balanced environments or server firms need some tweaks.
You can also have a look at the question and solution here