I host a website on a local network with XAMPP. I usually access it with the IP address on another device.
How can I host my website on a domain like website.local ?
- 161
- 2
- 9
-
Use [multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) (mDNS). What you need to set it up is depends on the platform you’re running the webserver on (which you did not mention). – StarCat Oct 10 '20 at 19:02
-
@StarCat I'm running Apache on windows – Anuja Nimesh Oct 10 '20 at 19:16
-
On what Operating System? – StarCat Oct 10 '20 at 19:16
-
@StarCat windows – Anuja Nimesh Oct 10 '20 at 19:18
2 Answers
The domainname does not matter. The other device must be able to resolve the name, so edit the /etc/hosts file on the other device and add a line like:
<wepserver-ip> <domain-name>
For example:
192.168.1.20 www.google.com
On Windows you will find the hosts file in %systemroot%\system32\drivers\etc folder.
- 121
- 4
-
1Already tried that, the website will be accessed by multiple devices. Some of them are mobile devices and sometimes new users will connect to the network. So that solution doesn't work. – Anuja Nimesh Oct 11 '20 at 06:05
You should be able to use multicast DNS (mDNS) for this purpose. To do that, you will need to set up mDNS on your computer. It seems to be a bit tricky to configure mDNS on Windows, and you might need to download Bonjour.
This question previously asked on SuperUser may provide some insights into how to solve your problem: How can I set up a 'local' domain so that everyone on my local network can view a locally hosted site?
Alternatively, you can try building an actual DNS server. Many routers have support for DNS and you may be able to add entries to it. The specific method depends on your router.
- 16