Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
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 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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.