Mobile app version of vmapp.org
Login or Join
Cooney921

: Why does typing in my site's IP address bring up a different site? I do not understand how domains are connected to IP addresses. I have a certain domain e.g. example.com. I run ping example.com

@Cooney921

Posted in: #Dns #Domains #Networking

I do not understand how domains are connected to IP addresses. I have a certain domain e.g. example.com. I run ping example.com and get its IP address from DNS query.

When I type this IP in address line in browser, it brings me to another site. Please explain to me the reason that might happen.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cooney921

1 Comments

Sorted by latest first Latest Oldest Best

 

@Fox8124981

The HTTP protocol that is used to load websites by your browser supports a "Host" header which tells the server which hostname was typed into the url bar of the browser. This way, the same server (same IP) can handle different websites.

Imagine www1.example.com and www2.example.com both resolve to 127.0.0.42.

The Server on 127.0.0.42 on port 80 listens to HTTP requests. If you open www1.example.com in your browser, the browser connects to 127.0.0.42:80 and sends the Host: www1.example.com header along with the request. This way the server can serve the site for www1.example.com.

If you enter www2.example.com, your browser also connects to 127.0.0.42:80, but this time sets the Host: www2.example.com header, thus the sever knows that this time it has to serve the other page.

If you open 127.0.0.42 in your browser, the server will get the Host: 127.0.0.42 header along with the request. This time the server may not know which site to serve, so it may present an error, or fall back to a default website. This is why you may see a different site if you browse to the IP instead of the hostname.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme