dns - How does my local HOSTS file resolve but IP will not -


i'm in process of launching new website. migrated code new server. admin @ new host told me have add entry hosts file , able see website. had me add:

111.222.3333.4444 example.com www.example.com 

these example, after doing this, worked. question is, how? if visit ip directly in browser 403 forbidden error. host have way resolve ip location on server if resolved domain name? i'm confused how works. understand changing ip address can domain name resolve ip, i'm wondering why, on hosts end, resolve way, not typing in ip directly.

thanks!

does host have way resolve ip location on server if resolved domain name?

not exactly. browser, when sending request ip address, send 1 important piece of information called 'host header', actual host name typed in browser.

you can not open website entering ip address in browser's address bar because web servers (and possibly many other network components between , web server) not host 1 web site on ip address rely on exact domain name typed in address bar serve right content.

you can test using 1 of browser add-ons allow add own headers. add header named 'host' value 'example.com' , try open site typing provided ip address.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -