msleone
msleone

Reputation: 227

IIS HTTP Redirect too many times error

I'm having some issues trying to set up a http redirect for a web application of mine in IIS. I have 2 DNS aliases assigned to the box "test.website.com" and "test1.website.com", I'm trying to redirect "test1" to test but it doesn't seem to be working. I have both URL's listed in the bindings and under the HTTP redirect form in IIS I checked the "redirect requests to this destination" box and put the "http://test.website.com" url as the link and also checked the "Redirect all requests to exact destination" as well. Status code is permanent, and I'm still receiving the ERR_TOO_MANY_REDIRECTS error and I'm not sure how to solve this. Any help would be greatly appreciated.

Upvotes: 0

Views: 14888

Answers (2)

Sam Arthur Gillam
Sam Arthur Gillam

Reputation: 438

The Problem

In IIS Manager, the HTTP Redirect form where you can specify a redirect destination does exactly one thing when you apply the changes: It adds a <httpRedirect> tag to the website's Web.config file. The image below illustrates the change.

enter image description here

In a perfect world, IIS would be smart enough to recognize that it has already come to the destination specified and not redirect. Sadly, IIS isn't smart enough. It will repeatedly search for itself. find itself, and tell itself to go back and search again. Eventually, the ERR_TOO_MANY_REDIRECTS error is thrown.

My Work Around

  1. Create a dummy website (a single page web app will do).
  2. Add an httpRedirect tag to the website's Web.config redirecting users to the website you want to make aliases for (in your case, "test.website.com").
  3. In IIS, create a new website that references your dummy website source code.
  4. In IIS, set the bindings of the dummy website to alias bindings for the website you want to make aliases for (in your case "test1.website.com")

Note

The content (or lack thereof) of the dummy website doesn't matter because visitors will be redirected away to the aliased website before they can view any of the dummy website's content. That being said, it might be smart to make the dummy website display a page informing any viewers that something went wrong when redirecting in case it ever is viewed.

Upvotes: 2

Brandon Spilove
Brandon Spilove

Reputation: 1569

The problem is you have both sites pointing to the same folder. Easiest thing to do is to move the test1 site to a separate IIS website in a separate folder. Keep the bindings separate, meaning put the test1 binding on the test1 site, and the regular test binding on the test site. Then put the redirect on the test1 site only.

Upvotes: 0

Related Questions