Local Browsing

A problem when running a website on the local network is that sometimes you cannot view the site even though the rest of the world can, typing the domain address into a browser can return the modem or routers configuration page. This happens due to a loopback on the network, which some routers do not handle well.

Single Website

When hosting a single website on a server the easy solution is to enter the local IP address into the browser and it will be treated the same as an external visitor.

Host Header Left Blank

Make sure when adding the site onto the web server leave the Host Header empty, this ensures the website is served regardless which path the request took to arrive. In this case the default website must be disabled as only one site on the server can have a blank host header.

Multiple Websites

Things get trickier when dealing with multiple websites as the host header needs to be defined, and this determines which website is served. To get around this we need to divert the visiting local computer to point at the server when accessing the site rather than looking online for it, this is done by editing the hosts file on a Windows machine.

Open Notepad as an Administrator:

WindowsWindows Vista / Server 2008 and newer: Right click Notepad in the Start menu and click Run As Administrator

WindowsWindows XP / Server 2003 and older: Open Notepad normally but needs to be done using an administrator account.

Go to File, Open and navigate to C:\Windows\System32\drivers\etc, then open the hosts file.

Default Hosts File

Entries in this file are allowed to bypass the usual internet DNS lookups and point to an address specified here.

At the end of the text document enter the local IP address of the server then a unique subdomain of the website like below:

Edited Hosts File

Adding a unique subdomain instead of the normal website address is good practise when using a laptop as it can be used when at home, but at a different location it can still be reached on the internet by using the original domain.

To be able to use the new subdomain in the hosts file, it needs to be added to the Website Identification or Host Headers information of the website.

Website Identification

This ensures that when the local. prefix is used before a domain the server will recognise and return a website.