Derek Hunziker
Derek Hunziker

Reputation: 13141

Canonical Hostname with URLRewrite 2.0 behind load balancer

I have two IIS7 web servers behind a load-balancer. The URL Rewrite 2.0 module is installed on both servers and the following rewrite rule applied to both instances:

<rule name="Enforce canonical hostname" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" negate="true" pattern="^www\.mydomain\.com$" />
    </conditions>
    <action type="Redirect" url="http://www.mydomain.com/{R:1}" redirectType="Permanent" />
</rule>

When I try to navigate to http://mydomain.com, my web browser hangs indefinitely. I suspect the load-balancer is affecting the way URL Rewrite works, but I can't be certain.

Upvotes: 0

Views: 2324

Answers (2)

Sumit
Sumit

Reputation: 3068

My guess is , 1. load balancer forwards your request to your child servers 2. and when request comes to child servers they redirect the request according to your URL redirect rule, so your request is redirected and again comes on Load balancer 3. and the same procedure(step 1-2) is followed,

thus your request loops again and again and your browser gets hanged.

Upvotes: 0

Derek Hunziker
Derek Hunziker

Reputation: 13141

We ended up using the following technique:

http://www.mcanerin.com/en/articles/301-redirect-iis.asp

The key was to add the $S$Q to the end of the domain name.

Upvotes: 2

Related Questions