I have configured wild-card sub domain mapping for my web application. I have changed "A" records in DNS settings for this. All requests to these new sub domains are working fine.
Ex: http://test1.foo.com, test2.foo.com
Later I configured IIS7 Canonical rewriting like the following:
<rewrite>
<rules>
<rule name="Enforce canonical hostname" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www\.foo\.com$" />
</conditions>
<action type="Redirect" url="http://www.foo.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
After adding the above code, all the wild-card sub domains are routing to http://www.foo.com.
I want all sub domains should work with out any problem with applying canonical rewriting.
Please help me.