-3

I have a web server (xampp) in a particular PC running on my LAN, and I added the following line in the 'hosts' file : 127.0.0.1 mysite.

Then, in another PC connected to the LAN, I'm trying to acces the previous web server by typing 'http://mysite/index.php' on the web browser, with no luck. But if I type the IP from the server computer (http://192.168.2.87/index.php) I am able to access the web site.

So, what should i configure so when i type 'http://mysite/index.php' I get the same result as http:// 192.168.2.87/index.php ??

Thanx!

fede
  • 1
  • 1
    The hosts files is only for DNS look-ups made by the local machine it's self that that hosts file reside on. So adding an entry to hosts on one machine is useless when trying to reference that name `mysite` from another machine. – jwbensley Sep 05 '12 at 20:43
  • Is this a duplicate question? It seems like there should already be a canonical answer which explains the purpose of /etc/hosts and the meaning of 127.0.0.1 . I cannot find such a question. – Stefan Lasiewski Sep 05 '12 at 20:45

2 Answers2

3

You should modify the hosts file of the other computer (the one that's not running the web server). It should contain a line like this one:

192.168.2.87 mysite
r.t.
  • 161
  • 3
0

The reason this happens is that the host file only affects the computer it's on. You'll need to modify the host file of every computer on your network if you wish to access the site from those computers using this method.

You'll also want to reference the web server by the machine's actual IP (192.168.2.87) when editing the host files of the other computers on your network. 127.0.0.1 is a loopback that references your current machine.

Steve G
  • 231
  • 1
  • 11