views:

1667

answers:

2

I have a Default Web Site and another web application (let's call it Application2) inside the Default Web Site in IIS7.

I have 2 registered domain names, let's say www.example.com and www.example.net.

I would like to configure things that when I open www.example.com I get Default Web Site, when I open www.example.net I get Default Web Site/Application2.

www.example.com -> Default Web Site
www.example.net -> Default Web Site/Application2

How can I do that?

+1  A: 

Edit... upon further investigation I found that if you can set up multiple sites and run them simultaneously. Just need to stop and start the sites after setting the host values to get them to both run at the same time.

Original post:

The straight-forward way to do this would be to add another application by opening IIS and right-clicking Sites then select Add Web Site. In there you can specify the physical path of Application2 and also set the "host" to "www.example.net" which will filter all those requests to your second site. Any requests that don't match "www.example.net" will still go to the default web site.

That approach will work fine on Windows Server using IIS, but on Vista's IIS7 it won't work since you can only have one site running at a time. To start the second site, you'd first have to stop Default Web Site.

DavGarcia
+2  A: 

First you need to decide if your going to use Name Based or IP Based hosting.

IP-Based uses unique ip's to determine which virtual host it will serve and Name Based will actually use the host header which is sent by your client browser.

So let's see two scenarios:

Scenario # 1 (ONE IP TO SHARE)

You have a server with only one IP, could be either private or public as long as the domains you are serving are properly configured in the dns serving you internally or your client externally (NAT).

I suggest that for the sake of this tutorial you stop the default website. Ok.

You will set up one site in II7 and name it accordingly. Go to the right hand side of the manager and look for "Bindings" under actions menu; making sure you have the new site selected on your left pane. Now under "Site Bindings" select the ip address you will be sharing between the sites (name based hosting). Under "Hostname" enter domain # 1 "www.example.com", hit ok.

Follow the same procedure above with the other domain or domains, making sure they have diferent hostnames and same ip's.

That's it. You will now be able to start those sites and run them at the same time.

The same principle above applies if your using the "Default Site". "Default Site" is just a name MS gave the default created one.

Scenario # 2 (MULTIPLE IP TO SHARE)

If you have either some private or public ip to spare, or at least until you do the exercise the only diference here is that sites you will set up and don't have to specify the "Hostname" per each site, as this is basically done in the DNS zones itself. The sites will respond for any request made to those ip's on port 80 regardless.

When will you need to use multiple Ip's to serve websites. Well it all depends.

Some reasons are: Network Isolation (Security), Applications which don't work well under name based hosting, SSL Certificates Bindings 443(PRE II7), and mostly complete control over site. There are of course more reasons, but I'll let others write a bit also.

Have fun.

Codex73