You may encounter “Page cannot be displayed” when using IIS HTTP redirect

If you are using IIS 7and above, as well as HTTP redirect to redirect requests, you might encounter this error:

1

I have a website, and would like to redirect all requests to its sub application test2:

2

So I would configure redirect rule like below in website level:

3

However when test browsing, would found above error, if you have any chance to check failed request tracing logs, you will find they are being generated ceaselessly, check the status code, you would find they all returned 302, and be redirected to https://hostname/test2 . you will find same result in IIS log:

4

This issue is caused by HTTP Redirect inheritance. If you navigate to application level, and open HTTP redirect, you will find the rule you add has been inherited for all subfolders and sub-applications.
To resolve this issue, you need to delete the HTTP redirect rule that hosted on application test2.
Try again, you should be able to get this rule work now.

In this article, I will explain more about HTTP redirect and its usage.

  1. First of all, there is heritance mechanism for “HTTP redirect”. If you configure this at IIS server level, all websites as well as subfolders and sub-applications will all inherit this http redirect rule.
    If you configure this at website level, all subfolders and sub-applications under this website will inherit this rule.
  2. So if you add this rule at server level, this rule will take effect for all incoming requests, not only for one website, if you have multiple website on this IIS, in this way, all requests to this server will still be redirected to your destination configured in HTTP redirect.
    But you could change the settings for other websites manually by unchecking the inherited rule, then all sub-level setting will be canceled.
  3. If you figure out there exists infinite redirecting loop, you’d better check all sublevel settings
  4. If you want to redirect all requests to specific page, you’d better check “redirect all requests to exact destination”. for example, if you want to redirect all requests to https://hostname/test2/index.html

If you didn’t check this setting, when you browse https://hostname/hello.aspx , you will be redirected to https://hostname/test2/index.html/hello.aspx .
If you checked this setting, in this case, you will be redirected to https://hostname/test2/index.html

5

More reference:

https://www.iis.net/configreference/system.webserver/httpredirect https://technet.microsoft.com/en-us/library/cc732969(v=ws.10).aspx

Thanks,
Cynthia Jiang from DEV team.