Saturday, August 8, 2009

How can serveral domain name be differentiated which being accessed since they belongs to ONE ip add

A http server hosts several domains,for example, www.example1.com, www.example2.com, and www.example3.com. But there is only one IP address. So the three domains correspond to the same IP address.



The problem is, if I enter www.example1.com into my browser address bar and hit %26quot;go%26quot;, first thing, this domain name will be resolved to an IP address, and then my computer just uses this IP address(plus a default TCP port 80) to fetch a web page. I very much know that different domain name will get different page. But how can the three domain name here be differentiated since they corresponds to one IP address?



I am very much confused by this problem and hope some tech-savvy persons can give me a clear explanation. Thank you very much indeed!



How can serveral domain name be differentiated which being accessed since they belongs to ONE ip address?





When you send a request for a website, for example www.fakedomain.com, the name of the domain you are requesting is included in something called a %26quot;host header.%26quot; The server that receives the request looks at this host header and is able to display the site corresponding to that information. This is called Virtual Hosting. The web server software is able to assign multiple domain names to one single IP address. The host header is what allows this to happen.



How can serveral domain name be differentiated which being accessed since they belongs to ONE ip address?



First, when your browser requests a web page, the Domain Name Server returns the I.P. address of the web server.



Your browser then requests the particular web page from the web server. Now the web server has information about the default folder for each domain name.



For example, say www.A.com and www.B.com use the same I.P. address. When you request A, the web server will look for the file in the public_html/A/ folder (for instance).



In a nutshell, the web server knows which is the root folder for the domain name and it resolves paths in web pages accordingly.

No comments:

Post a Comment