Iis – Setting up a domain name to use host headers

domain-name-systemhost-headersiis

I have a server that I want to host multiple web sites on using host headers. I know how to set IIS up but I am unsure how to set up the domain name. I have a domain name (ex. mydomain.com) that I want to redirect to an IP address (12.138.XXX.XXX).

Do I create an "A" record to redirect the domain to the IP address and a CNAME record to hold the host header value? I can get the domain name to redirect but IIS doesn't direct it to the correct web site.

Best Answer

Adding onto what the others have said and clarifying it. Yes you're getting mixed up between DNS and Host header. The DNS system is just for resolving names. This is how it works.

Basically in the browser you'll enter in a URL like:

http://www.example.com

In DNS, an A record for www.example.com resolves to 93.184.216.34.

Lets say that 93.184.216.34 is your very own web server running IIS.

It's the browser that sends the host header. The browser would send a request to the web server which will look something like:

GET / HTTP/1.1    
Host: www.example.com  

The web server which may be hosting multiple websites sees www.example.com and serves up that website.

If you want to add another website, you'd configure another website in IIS and tell it what host it's for, and add another website domain to DNS which also points to your webserver at: 93.184.216.34. i.e. just add another DNS A record entry for the domain and you're set.

I hope this makes sense.