2

Now this is really basic. I've read about how DNS works. There are also some questions at ServerFault that talk about complex DNS configurations and stuff but my problem is that I don't get the basic of it. My question is pretty simple, even embarrassing but there's something huge I'm missing and it's driving me crazy.

When you need to link a domain name with a web hosting server, you have the domain name and the DNS of the hosting server and you point the domain name to the DNS server (either hostname or IP).

But how do you tell it which website should it display in a shared hosting? There is more than one website with the same IP.

Thank you!

Xavi Esteve
  • 145
  • 5

2 Answers2

1

On shared hosting, your provider will have a control panel to set that up for you. If you're setting up Apache yourself, this is stored in the vHosts portion of the config file.

Essentially, the webserver (usually Apache) figures out which webpage to serve to the end user, since every modern browser sends the HOST header indicating which hostname it intends to access. If you browse to the IP without telling the server which website you want to visit, most webservers display a generic error unless configured otherwise.

Paul McMillan
  • 1,219
  • 1
  • 8
  • 17
  • That's what I was missing! I didn't realize it is the provider who needs to set that up in a shared hosting, thought I had to do it myself. Thank you Paul! – Xavi Esteve Oct 15 '10 at 20:05
  • Yep. Usually you enter the domain somewhere in their control panel, and 15 minutes later it goes live in the server's apache config. – Paul McMillan Oct 15 '10 at 20:14
  • This (by the way) is why it's silly for a provider to charge you extra for each domain name you use - it's essentially 5 lines in a config file, but not much else as far as resources go. – Paul McMillan Oct 15 '10 at 20:15
1

When there is more than one website on an IP, the web server looks at the HTTP host header in the request to determine which site to serve.

In Apache, this is set up through Virtual Hosts. In IIS, through Host Headers.

phoebus
  • 8,380
  • 1
  • 31
  • 30