Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between specifying IP in host file vs using IP directly

Is there any difference between the following when a intranet URL in accessed in IE

Add an entry in drivers/etc/host file for a name and IP vs Use IP directly

e.g. it works with the following link if I have a host entry as (XYZ 10.0.10.200)

http://XYZ/SiteDirectory/ABC/Default.aspx

but when I tried to use IP instead of name

http://10.0.10.200/SiteDirectory/ABC/Default.aspx

It gives me 404 not found error

like image 853
usman shaheen Avatar asked Dec 07 '22 07:12

usman shaheen


2 Answers

Yes, there's a difference.

The web server is using HTTP/1.1 and "shared virtual hosting". When the client connects it sends an additional Host: header which contains the hostname part of the URL that the user supplied.

The web server looks at the header to find out which virtual host's data to serve.

In this case, the web server is configured to recognise and serve content from the "XYZ" domain, but doesn't know about any domain called 10.0.10.200

like image 83
Alnitak Avatar answered Dec 11 '22 08:12

Alnitak


Smells like the webserver is using virtual hosts, so that it serves different pages if the client went to "www.foo.com" or "www.bar.com", even though they have the same IP-address.

like image 45
Jonatan Avatar answered Dec 11 '22 10:12

Jonatan