2

I am trying to set up http to https rewrite in IIS 8.5 using the Rewrite module. Absolutely nothing I have tried has any affect whatsoever. The URL is of the form: http://users-dev.somedomain.com. The rule currently created in the web.config is:

<rewrite>
  <rules>
    <rule name="Redirect to HTTPS" stopProcessing="true">
       <match url="(.*)" />
       <conditions>
          <add input="{HTTPS}" pattern="^OFF$" />
       </conditions>
       <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
    </rule>
  </rules>
</rewrite>

And I have tried many variations since. Earlier tinkering with URL rewrite I could see various rules taking effect, but it seems now that nothing I do has any affect at all...I suspect something is up with IIS. I have also tried an IIS restart, to no avail...

Any ideas?

  • Enable Failed Request Tracing and search for RewriteModule in the logs. – Peter Hahndorf Jul 31 '15 at 16:05
4

It turned out that under the sites SSL settings the "Require SSL" checkbox was checked. If this is checked the client cannot get through on port 80 at all and the rewrite never happens...

If you are using the rewrite module you cannot have "Require SSL" checked as the initial request needs to be able to get through on port 80.

2

Well, I thought I ran into the same case as MrLane on IIS 8.5.

It took me day to find out that I had not have the website running on the port 80.

I just add this binding (port 80) and the rule work as expeceted.

Hope this can help to solve MrLane's case.

0

This works for me:

<rule name="Redirect to HTTPS" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
                <add input="{HTTPS}" pattern="off" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
  • Yep I have tried this as well, no change. I think something is wrong with the rewrite module |: – MrLane Jul 31 '15 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.