Search code examples
http-redirectiis-10

IIS Http redirect


I have couple of questions regarding IIS configuration.

When I enable HTTP redirect in IIS and use http://localhost/SubApp it's redirected to https://localhost/SubApp, but when it's http://localhost/service.svc it's not redirected to https://localhost/service.svc.

Also with redirect enabled URL like this https://localhost/test.html is not opened, I see message

Can’t reach this page. Make sure the web address https://localhost is correct.

Content of file very simple: <html><body>test html</body></html>.

However when HTTP redirect disabled I can open this URL. I have self-signed certificate.

Config for HTTP redirect is

<httpRedirect enabled="true" destination="https://localhost" exactDestination="false" childOnly="false" httpResponseStatus="Permanent" />

So, questions are:

  1. Why *.svc is not redirected to HTTPS protocol?
  2. Why https://localhost/test.html can't be opened with enabled http redirect?
  3. Does it all mean just use url rewrite module and get rid of redirect configuration?

Solution

  • After tests we have found out that the only possibility to use HTTP redirect (from HTTP to HTTPS) is:

    1. Configure HTTP binding for the main site so port changed from 80 to 81. Also, port 81 is not visible from outside
    2. Add new website with HTTP binding to port 80, this site has empty WWWRoot
    3. Add HTTP redirect to this new empty website so it redirects to HTTPS of our main site.

    In this case HTTP redirect works fine.