Setting your hosts file in Windows
If you have built a site that doesn't currently have a domain, or you've built a site using our hosting but there's a live site hosted elsewhere, using your hosts file is one of the easiest, most effective ways to preview how your site looks on our servers.
What does it do?
Normally when you put 'yourdomain.com' into a browser, it will use a name server to look up what IP address is associated with that domain in order to find the website, however when you're previewing a site under the conditions described above it is not possible to use name servers.
Your hosts file performs a similar task, associating host names with IP addresses, and by adding a single line to that file we can tell your computer “When you go to 'yourdomain.com' look for it at this IP address”
How do I do it?
Before we do anything, you need two three pieces of information
- The domain as it appears on our servers
- The IP address of the server your site is hosted on
- Your administrator password for your computer (if your account isn't an administrator account)
When you have those three things we will need to open up a basic text editor such a notepad as an Administrator, which you can do by finding notepad on your computer (usually through your Start Menu > Program files > Accessories > Notepad), right clicking it and then clicking “Run as Administrator”
Once you're in Notepad click File, Open and to find the hosts file follow this directory path;
C:\ Drive (or main windows partition) > Windows > System 32 > Drivers > etc > hosts
If you don't see any files in the etc folder, simply type “hosts” in the “File name” bar, or set the drop down menu to view “All files."
This is your hosts file, and we are going to be adding some information in a new line which will allow you to preview your site without anyone else being able to see what you see.
At the bottom of the file you will need to add the IP address of your server, “yourdomain.com” and “www.yourdomain.com”. So it will look like this
126.96.36.199 yourdomain.com www.yourdomain.com
And that's it! Save the file (file, save) and make sure to save the changes and you're done.
Now when you visit yourdomain.com your hosts file, rather than a name server, will tell your browser where to look for the site.
When you're ready to view the site how everyone else sees it, simply follow these steps again and remove that line from your hosts file