Search code examples
apachelocalhostwampwampserver

WAMP custom url working on host machine but not on other


I've set up a WAMP server on my laptop and gave it a custom url.
I can access the website both using the ip (of my laptop) and custom url.

When I try to connect from my PC using the custom url, it doesn't work.
It just outputs an error saying :

Server Not Found

I can connect to the website from my PC using the ip.

So, why can I connect using the url on my laptop (host) but not my PC and how do I fix it?

My local IP : 192.168.1.117
My custom url example : example.local


Solution

  • The Custom URL as you call it, or Virtual Hosted Domain as it may better be described only works because on the PC Running WAMPServer you added that domain name example.local to your HOSTS file.

    So if you want that to work from another PC in your local network you must also make that change to the HOSTS file on that/those other PC(s)

    So add this to the hosts file on the other PC

    192.168.1.117 localhost
    

    The IP Address 192.168.1.117 is the ip of your WAMPServer PC.

    Big Note:

    Make sure that the WAMPServer PC has a Static IP Address and NOT a dynamic ip allocated by your routers DNS Server, or on reboots, the WAMPServer PC's ip may change and then the other PC's in your network wont be able to find Apache.

    Also you will have to chnage the Virtual Host Definition to allow Apache to accespt connections from PC's other than the one running WAMPServer

    So you will need to change the httpd-vhosts.conf file and add the following to

    Require local
    

    so it looks like

    Require local
    Require ip 192.168.1
    

    The Require ip 192.168.1 allows any ip in the 192.168.1 subnet to connect to Apache