0

I set up a couple virtual hosts in order to point to different resources on the network that I want accessible from links on my index page. I set these to ports 81 and 82. On my index page, I link directly to the IP, like so: <a href="http://127.0.0.1:81">

I assumed this would let me get away with not configuring the host file to look for the server name. I'm setting up a simple information-distributing intranet to make accessing certain files easier for about 60 computers, so it's easier if I don't have to modify all of their host files.

This method works locally, but not from another computer. From another computer, I can access my computer's XAMPP root directory /htdocs by navigating to the computer name, which gives me my main index, but the link are broken. Is there any other way I can link to these vhosts from my index that will work on a different computer?

0

127.0.0.1 is localhost, meaning "this machine", so naturally you can't use that to connect to a service on another machine. You need to use the actual ip address of the server hosting that service.

The hosts file is used to resolve names to ip addresses. If you're accessing the server by ip address then the hosts file wouldn't be used.

  • thank you, that makes sense. If I navigate to http://mycomputername from any computer on my network, it will take me to my localhost directory; is there a way to specify the path to the vhosts using my computer name? – Pawtang Mar 29 '18 at 14:19
  • You need to access the server hosting the websites by name or ip address. If you want to access it by name then you need to either populate the hosts file on each client machine or you need to use DNS. – joeqwerty Mar 29 '18 at 14:21
  • It works! I can use either http://[local_ip]:81 or http://[computer_name]:81 from another network computer – Pawtang Mar 29 '18 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.