How to check a specific web page in the host file

skippy647

Distinguished
Aug 3, 2012
137
0
18,680
This is my example below.
say i wanted to check www.google.com using 8.8.8.8,

In the Hosts file, I would write:
8.8.8.8 www.google.com

But if I wanted to check www.google.com/images-for-you
(a url I just made up)
How would I write this? Can I do this?

it wouldn't be just

8.8.8.8 www.google.com/images-for-you

would it?
 
Solution
Although we got side tracked by your example the issue is still the same. The host file function like DNS only function is to translate a domain name to a ip address. It has no ability to process any information that is past the domain name itself.
Host file and dns name have nothing at all to do with URL. The URL just happens to contain a host name but other than that there is no relationship.

Only the host part of any url is converted to a IP address. The rest of the line is data that is passed to the application on the server at that ip.

Now all kinds of messy things can be done by the server telling you web browser to say open a different web page on some different server but this is all part of HTTP not a function of name resolution.

In the example you give you are confusing the google dns serer at 8.8.8.8 and www.google.com which is not using that ip address.
 

skippy647

Distinguished
Aug 3, 2012
137
0
18,680


So if this is the case,
If I go to any page beginning with www.google.com,
(like www.google.com/images-for-you)

I will still be connecting to the page using 8.8.8.8 correct?
The whole domain is 8.8.8.8.

That sounds correct in my head.
 
8.8.8.8 is the IP address for one of Google's public DNS (Domain Name System) servers.

tracert 8.8.8.8

Tracing route to google-public-dns-a.google.com [8.8.8.8]
over a maximum of 30 hops:

The hosts file is used to map host names to IP addresses.

You're trying to do something that the hosts file doesn't do.
 

skippy647

Distinguished
Aug 3, 2012
137
0
18,680


I was using an example. Im not actually trying to do that.
 
Although we got side tracked by your example the issue is still the same. The host file function like DNS only function is to translate a domain name to a ip address. It has no ability to process any information that is past the domain name itself.
 
Solution

skippy647

Distinguished
Aug 3, 2012
137
0
18,680


Thank you, thats all i wanted to know