«

»

Nov
25

Using Windows hosts file to browse a site in development before domain is pointed.

As a good way to test a site on a production server I have been using my Windows hosts file to allow me to browse with the actual domain name before it is switched to point at the server.

This allows me to test and configure the site using the correct base url as it awaits domain propagation.

To set your hosts file I recommend the following steps:

  1. On a Windows machine click the Start button and in the Accessories folder find Notepad – but don’t left click it open, instead right click for a menu that includes the option to “Run as administrator” – select this and Notepad will open
  2. Use the File menu in Notepad to select Open… then browse to C:\Windows\System 32\drivers\etc – you will probably see a blank folder and this is because by default Notepad is set to look for files of type .txt – so using the drop down there select All Files (*.*) which will reveal the files without extensions, you should now see a file called “hosts” – open this file
  3. At the bottom of the file insert your hosts directive which has the format of IP-address space domain-name, for example:

    23.23.253.12 domain.com

    (do *not* use www. in your domain name!) once you have inserted this line click Save and close Notepad.

Now when you enter this domain name, without the www. part, in any of your browsers it will direct your request to the IP address you specified. To view the actual website the domain is pointing to before you switch it to the new server just use the www. in front of the domain e.g. www.domain.com – this will bypass your hosts directive.

It should be noted that the domain name must have an account on the IP address to begin with!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>