Copyright © 2008-2019 Paula DiTallo

Tag Cloud

How do I Configure Multiple Web Sites in IIS or How do I Add/Edit Host Headers?

You may need to map multiple web sites with the same port number or you may want to map an IP address that has been set to a netscaler vip/ip to multiple servers. IIS 6.0+ allows you to do that with a feature called Host Header Names. For the official details, review Microsoft's web site:

Here's how it works:

Let's say you have a DNS entry called @ ip address:  and one of the load balanced twins (ServerAlphaTwin) has an address of and the other (ServerBetaTwin) has an address of

To set this up on the ServerAlphaTwin you would do the following:

1. Click Start> Administrative Tools, and then click Internet Information Services (IIS).
2. Where you see the name of the server (in this case ServerAlphaTwin), expand Web Sites.
3. Right-click the Web site that you need to change (usually Default Web Site), click on Properties.

The Properties dialog box will appear--once it does do the following:
4. Click on the Web Site tab, click Advanced.
5. Under Multiple identities, click the IP address, and then click Edit.

When the Advanced Web Site Identification dialog box is up:

6. Under the Host Header Name, type the host header that you want. In this case, type
7. Add the port number (usually 80)
8. Select the IP address in the list if there, if not type it in. In this case it would be (  and then click OK.

What you will see in this dialog box for ServerAlphaTwin is:

IP Address               TCP port          Host Header Value         80                    <default>         80           

For ServerBetaTwin repeat steps 1-9, replacing the ip addresses accordingly.

What you will see in the Advanced Web Site Identification dialog box  for ServerBetaTwin is:

IP Address               TCP port          Host Header Value         80                     <default>         80           

 So now both the Alpha and Beta servers can be accessed by addressing the MetroDesignDev.LoadBalanced.Twins !

Wednesday, November 5, 2008 2:40 PM


# re: How do I Configure Multiple Web Sites in IIS or How do I Add/Edit Host Headers?


In our application I have to create a domain at for each registered users. I have created the domain( for each user at godaddy with the A record of my staged server IP. If I click the domain name my user profile should be open. In our staged server I need to add a host header value and port number programatically in IIS using with c#. please help me regarding this.

Subburaj.S 3/16/2009 1:17 AM | Subburaj

# re: How do I Configure Multiple Web Sites in IIS or How do I Add/Edit Host Headers?

Subburaj. S--

Here is some starter code for you on inserting new host headers with c#/system.directoryservices reference.

Another helpful reference is from Walt Oliver's blog:

------------------- starter code -----------------------------------------------------

// general example to add host headers -- if you need to add more than 1, wrap this logic in a
// foreach or while loop.
using System.DirectoryServices;
using System;

public class IISHostHeaderTest

public static void InsertHostHeader(string hostHeader, string yourSiteID)

DirectoryEntry yourSite = new DirectoryEntry("IIS://localhost/w3svc/" + yourSiteID );
//yank whatever is in the serverbindings property.
PropertyValueCollection serverBindings = yourSite.Properties["ServerBindings"];

//copy the content to new array
Object [] freshBindingList = new Object[serverBindings.Count];
serverBindings.CopyTo(freshBindingList, 0);

//Write to iis metabase
yourSite.Properties["ServerBindings"].Value = freshBindingList;

catch (Exception e)


//----------- to call this code chunck do the following:
//test driver
public class TestIISHostWriteApp
public static void Main(string[] args)
IISHostHeaderTest.InsertHostHeader("", "1");
} 3/16/2009 3:14 AM | paula ditallo

Post A Comment