When The domain is just being migrated to the new server or while setting up new website on the newly acquired domain, we always feel the need to access the website so that its proper working can be ensured.
At the same time we do not wish to update the domains DNS record as we wish to keep it Live For the World To Access..
Well.. we can achive this by simply editing a file on our local machines.. This way we are not supposed to edit the DNS records & still we can access our site on new server.
Basically what we are doing is guiding our local machine to look our website on the perticlar server irrespective of where the DNS records for the domain are getting pointed..
This can be done by editing hosts file on the local machine.
If this sounds intresting lets begin with setting up the hosts file. We are taking scenario that we have Windows 7 As the OS On the local machine and we are trying to access the domain thelinuxchef.com from the server
with ip 192.168.1.1
Open the hosts file by executing this below mentioned command in Run Line to edit the host file
Once notepad is open you can edit the file. As mentioned above we will point the domain name thelinuxchef.com .
Write the lines in the format as below
Ip address domain name
The Example is shown below
Now save the File
If you are getting error as below while opening the hosts file
Access to C:\Windows\System32\drivers\etc\ hosts was denied
To resolve this issue, follow these steps:
Click Start >> click All Programs>> click Accessories >> right-click Notepad >> and then click Run as administrator.
Now when you will access the domain thelinuxchef.com you will be able to see the website which is there on the server 192.168.1.1 irrespective of the server where actually it is pointing.
If you are having any other OS on then please check the table below showing the location of hosts file . You may refer to it and edit the hosts file to access your domain before updating the DNS records.