The Microsoft URL Rewrite Module for IIS 7.0 provides a flexible rules-based rewrite engine that can be used to perform broad spectrum of URL manipulation tasks, including, but not limited to:
Enabling user friendly and search engine friendly URL with dynamic web applications;
Rewriting URL’s based on HTTP headers and server variables;
Web site content handling;
Controlling access to web site content based on URL segments or request metadata;
In this KB I will walk you through the steps to route multiple domains to subfolders in your site. An example of this would be if you are hosting www.Peanutbutter.com and www.Jelly.com on the same website.

With URL Rewrite you can create rules to direct traffic to subfolders based on the URL.
In IIS7.5 (and also applicable to IIS7) you will first need to install the URL Rewrite Module. The download can be obtained from www.iis.net/extensions. Once you have done that you will now see a new Icon in IIS.

Create URL Rewrite Rule
1. Click the URL Rewrite module.
2. Add Rules
3. Blank Rule
4. Name = Virtual Director (Or whatever friendly name you would like)
5. Pattern = .*
6. Add Condition
a. Condition Input = {MyDomains:{HTTP_HOST}}
b. Input String = Matches the Pattern
c. Pattern = (.+)
7. Action Type = Rewrite
8. Rewrite URL = {C:1}{REQUEST_URI}
9. Click Apply
10. Click Back to Rules

Create Domain Routes
1. Click View Rewrite Maps
2. Click Add Rewrite Map
3. Rewrite map name = MyDomains
4. Click Add Mapping Entry
5. Original Value = Domain you want to route (i.e. Jelly.com)
6. New Value = Folder you would like traffic routed to (i.e. Jelly)
7. Repeat steps for any third level domains you also want to route (i.e. www.Jelly.com)

Now while both Jelly.com and Peanutbutter.com are both bound to the same site, traffic for Jelly.com gets routed to one folder down. If you look in the address bar it masks the folder /Jelly

You can do this for as many domains as you would like. Domains not listed in the Rewrite Maps will continue to load their pages from the root of your site.
If you wouldn't want to go through all those steps through the GUI you can include the following code in your web.config
<system.webServer>
<rewrite>
<rules>
<rule name="Virtual Director" enabled="true" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{MyDomains:{HTTP_HOST}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}{REQUEST_URI}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="MyDomains">
<add key="Jelly.com" value="/Jelly" />
<add key="www.Jelly.com" value="/Jelly" />
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
02fe2508-4fd2-4332-9dfa-71655aca3631|0|.0
IIS 7, URL Rewrite
url rewrite, iis 7