question

GaryTarr-5142 avatar image
0 Votes"
GaryTarr-5142 asked GaryTarr-5142 commented

Problem with url rewrite on iis 8.5 server 2012 r2

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>

windows-server-iis
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your help. I enable the logging and the rule started working. I can't explain it. I then disabled the l logging it it continues to work.

0 Votes 0 ·

@GaryTarr-5142 It may be caused by the cache. If you get this problem again, try to clear the browser’s cache and try again.

0 Votes 0 ·
Show more comments

0 Answers