Why when I browse to a host name I have mapped in my hosts file I get a different site?



  • 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?



  • 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


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2