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

I have an discount account, which uses IIS 7 and I want to configure subdomains to point at specific applications on the site.

For instance:

'' would run the application at ''. I would like the subdomain to be opaque so that users do not have to deal with the /serverone part.

There was a similar question on server fault, but it involves creating a whole new site for each subdomain, where as I would rather just route to independent applications in subdirectories for each subdomain.

Also discount provides a script-based programmatic solution, but this is obviously a less desirable and flexible solution, and probably results in reduced performance (though I have not actually measured the difference between the two methods).

share|improve this question

I'm not sure how discount's control panel works, but if you were doing this directly in IIS, you need to create a separate site for each application, not necessarily each subdomain, if there are more than one subdomain per app, then set it up with bindings for each subdoamins URL. The root of each site would then be your apps folder. You can't just use a subfolder of the main site, as you cannot add bindings to a folder.

Alternatively, you can use URL Rewrite to Rewrite request for to

share|improve this answer
By separate 'site', do you mean separate 'application'? I only have access to one 'site', but I like to route the subdomains to different application subdirectories on that 'site'. – Mark Rogers Mar 24 '10 at 15:22
Well I mean a seperate site in IIS, so if you only have one site in IIS, then you will need to look at using URL Rewrite – Sam Mar 24 '10 at 15:23
Could you give a url rewrite rule example for the -> ? You would make my life much easier... I'll beg if you like :) – Mark Rogers Mar 24 '10 at 15:23
Take a look at this article… – Sam Mar 24 '10 at 15:30
Ok, thanks, have a nice day – Mark Rogers Mar 24 '10 at 15:32
up vote 2 down vote accepted

Using the URL Rewrite, that Sam Cogen mentioned, which is automatically installed in any discount account (and which can be installed to any IIS7 server), I created a rewrite rule to solve my problem.

Note: The staff at discount said that a rewrite rule is the only way to accomplish this on one of their accounts besides a programmatic script. Discount provides a programmatic (I say hack) script that will route subdomains to subdirectories, but I needed more flexibility and performance than such a solution would provide.

If the IIS 7 rewrite module is not installed, you will have to find the module (probably at microsoft's IIS website), and then install it.

Once the rewrite module is installed in IIS, connect to it using the IIS Manager.

Make sure you have the root level of the website selected when you create the rule (rather than the subdirectory where your application is), this is very important because it led me to a critical mistake that wasted some time. The rewrite rules can be applied at different levels in the directory hierarchy, causing a rule to have different effects depending on where in the directory hierarchy the rule is located (I believe it makes a change to the local web.config, when a rule is created, but I have not taken the time to confirm this). This also means that you can't see the rules set in other directories when you are altering rules in another directory.

Selecting the root directory for the rewrite is important because you want to reroute all subdomain urls to the subdirectory url (except ones already routed to the subdirectory).

Having selected the root site directory, double click URL rewrite, to enter the rewriting area. Then click Add Rule(s) and create a Blank Rule.

For the matching

Pattern use: ^(?!serverone/)(.*) and set

Requested URL: to 'Matches the Pattern', and

Using to Regular Expressions.

This will route any url through this rule, ignoring those that are already headed to the correct subdomain but we want to restrict the rewrite from routing stuff that doesn't have the subdomain in the url, so next we will add a condition.

It only needs one condition, using {HTTP_HOST} for input, and the pattern for it is:

Finally for the Action, you need an 'Action Type' of 'Rewrite' that appends the query string value.

The rewrite url should be: serverone/{R:0}.

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.