In this article you will learn how to modify your hosts file if you want to work on a site that is not yet live
Usually when you are building a new website first you are choosing a domain name by buying the rights to use it from a registrar. Then the second step is to choose a hosting company to host your website and the third step is to build the website.
After acomplishing this 3 steps you need to contact your registrar to direct the DNS servers to point web requests for content on your site to the server that is hosting it.
Most hosting companies provide a temporary alias that is added to your domain name and you can work on your site before making it public. If you don’t have a temporary alias or don’t want to use it, but you need to access your website before contacting your registrar, you can modify the hosts file of your local machine.
The hosts file is that file that all browsers look at when getting a new website request prior to going to their DNS server. When you enter a website in your browser, your computer first looks at the hosts file for information and if it doesn’t find the website there, it asks the ISP’s DNS server to locate the IP address of the site.
To Modify the Hosts File on a Windows Machine
Note: Because Windows protects the hosts file from modification by malicious programs you need to run Notepad as an administrator. To do that:
1) Press the Windows key on your keyboard, type Notepad, but do NOT press Enter.
2) Right click on Notepad and select Run as Administrator.
3) Navigate to C:\Windows\System32\drivers\etc.
4) Open the file
5) Add the IP address of the server that is hosting your website.
6) Press Tab and add the domain name of your website.
7) Save the hosts file.
If you are not allowed to save the file because of some security policies on your machine you can:
1) Save the file with a different name, like hosts_new for example.
2) Close Notepad.
3) Delete the original hosts file and rename hosts_new to hosts.
The other approach is to copy the hosts file to your desktop for exmple, modify the file there and after that to copy and paste the file in its default location: