When you connect to your home-hosted website by name, the name resolves to an IP address. That IP address is the address of your home router. And your home router is designed to assume that any connection to the web server port coming from inside the home is intended for the router's administration pages— even though you have carefully configured the router to forward connections on port 80 (the web server port) to your home-based web server.
So how do you work around the problem without buing a better router? If you just need to test your home web server from one of your PCs, you can edit the hosts file on that PC so that the name of your web server automatically resolves to the internal IP address of your home web server. When your computer needs to translate a website name to an IP address, it consults the hosts file first before consulting DNS servers, so we can use this technique to avoid involving your router when your home PC connects directly to your home-hosted website.
On Windows XP, the hosts file is located here:
c:\windows\system32\drivers\etc\hosts
You will need to open this file with Notepad and add one line at the end. Here I assume that your home-hosted site is called example.is-a-geek.com and that the internal IP address of your home-hosted site is 192.168.2.100, but you must use the correct name and internal IP address for your site. If you don't understand this, you should read how do I host my own website at home? before continuing.
Here's the line to add to your hosts file:
192.168.2.100 example.is-a-geek.com
If you are running MacOS X on your home PC, you can still edit your hosts file. In your case the file is at the location: /private/etc/hosts
Linux users can find their hosts file at: /etc/hosts
Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.
Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!
Follow us on Twitter | Contact Us
Copyright 1994-2012 Boutell.Com, Inc. All Rights Reserved.
