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?
Asked
Active
Viewed 49 times
1 Answers
2
Web-servers use something called vhosts. The server separates sites on the hostname, this allows multiple websites to be hosted on a single IP.
hostname1.domain.com -> IP -> serve files from location: /disk/webserver/website1 hostname2.domain.com -> SAMEIP -> serve files from location: /disk/webserver/website2
You can also setup the webserver to direct to a website when you have no hostname, when you access it directly onits IP.
http:// IP -> /disk/webserver/website3
Niels van Reijmersdal
- 32,520
- 4
- 57
- 124