Problem with url rewrite on iis 8.5 server 2012 r2

Gary Tarr 1 Reputation point
2021-09-02T19:47:58.593+00:00

I am trying to rewrite any http request to an https request. Below is my web.config file. It seems like the setup is correct but it is not working. If I try to visit my site with an http request, the site appears but does not automatically redirect to https. Any ideas would be much appreciated.

Thanks
Gary


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="default.aspx" />
<remove value="iisstart.htm" />
<remove value="index.htm" />
<remove value="Default.asp" />
<remove value="Default.htm" />
</files>
</defaultDocument>
<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}/{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Internet Information Services
{count} votes