Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is similar to Redirect subdomain to subdomain on new domain except I'm using IIS 7. The application is ASP.NET framework 2.0.

I have a url and I need to redirect to

I need to maintain the subdomain but I need the domain to change so that the user never sees, and I have X number of cust subdomains.

I am able to route everything where it needs to go using DNS, but I can't figure out how to change the domain so that is never displayed. I was hoping to make this a 301 redirect, but from what I have read so far I don't think that's possible.


share|improve this question
up vote 1 down vote accepted

Yea, I answered my own question!

For IIS 7 you can install the URL Rewrite Module from the MS Web Platform Installer or download it separately. Once installed, this essentially gives you the power of mod_rewrite in IIS.

To solve my redirect issue I created a new redirect entry as shown below. The URL Rewrite module provides a user interface for creating the redirect which then writes the entry to the site's web.config, like many other IIS modules.

            <rule name="RedirectToNewDomain" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                <match url="*" />
                <conditions logicalGrouping="MatchAny">
                    <add input="{HTTP_HOST}" pattern="**" />
                <action type="Redirect" url="http://{C:1}{C:2}{PATH_INFO}" appendQueryString="false" />

What I am doing with this redirect is allowing all urls into the rule with the wildcard match url="*". Then I am conditionally pattern matching on the old domain. The asterisks in the conditional pattern match allow me to have back-references to whatever matches the pattern, which I then plug as {C:1} & {C:2} in the redirect action. It's the {C:1} back-reference that allows me to maintain my subdomain during the redirect and is the answer to the problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.