I am testing a website and have been asked to map a host name (the live website url) to an ip address in my hosts file. My understanding is that this means when I browse to the host name, instead of seeing the live site, I am redirected to the ip address it is mapped to (the test site). This all works fine and I see the test site, what I don't understand is why I see another different test site if i browse directly to the ip address? And if I have two host names mapped to the same url in my hosts file I can see a different site when I browse to each of the host names? How is this possible?
You can also setup the webserver to direct to a website when you have no hostname, when you access it directly onits IP.