Modifying the hosts file

What is host file?

A hosts file is an address book, situated on your local desktop, that maps a host name to an IP address (network name resolution). Generally, a domain name (host name) is translated in to IP address via the DNS resolution process. However, the host entries that are present in this file will bypass this DNS resolution.

This can be of great help when:

  • You have modified the Name Servers, and are viewing the cached results due to the DNS propagation delay.
  • You are in process of migrating the hosting server, and want view the website on the new server when its still under development. This way you can preview the site in the developmental stage, whereas your visitors will continue to view the live website on the old server. Thus, the traffic to your site remains unaffected.

Note

You can also use the Direct/Temp URL to preview the site on Shrishti Softech Solutions (P) Ltd's server.

Creating a hosts file.

To view the results with such immediate effect, you can define a host/domain name in the hosts file.

For Windows

1.Go to C:\Windows\System32\drivers\etc and locate the hosts file.

 

  1. Open it in any text editor like Notepad, Notepad++, etc.
  2. Add your host entires as shown in the snapshot below and save the file.





For Linux.
  1. Locate the hosts file at /etc/hosts.
  2. Run the below command to edit file:

vim /etc/hosts

  1. Add your host entires as shown in the snapshot below and save the file.

Note

You may also need to flush your DNS. Your website's IP address may be saved in your computer's cache. So you need to clear this temporary data so that the IP address you just entered into your hosts file will take effect. To do so:

For Windows :-

  1. Click your Start Menu.
  2. Go to Accessories and then click Command Prompt.
  3. Run the below command:

C:\> ipconfig /flushdns

      4. The output would be similar to:

For Linux

  1. Login into the shell of your machine.
  2. Run the below commands:

root@support [~]# cd /etc/rc.d/init.droot@support [/etc/rc.d/init.d]# ./nscd restart

  1. The output would be similar to:

If you have any browsers open, close them and then open them again. You should now be able to successfully test your website on your new server.

  • 2 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

Purchasing a Hosting Order for Internationalized Domain Name (IDN)

In order to purchase a Hosting Order for an Internationalized Domain Name (IDN), you need to...

Ports open for outgoing connections

Shrishti Softech Solutions (P) Ltd has opened the following ports for outgoing connections on its...

Switching PHP Version

cPanel Hosting Shrishti Softech Solutions (P) Ltd supports PHP 5.2, 5.3 and 5.4 on its cPanel...

SMTP Server settings for sending mails through your website

All Shrishti Softech Solutions (P) Ltd Web Servers have SMTP Server installed and are capable of...

Debugging Perl/CGI Scripts

Hosting servers are configured to store error logs for CGI/Perl scripts, encountered during the...