Select a Category

How to Change Host File

Problem

If you want to test your website without modify your domain name server (DNS), you can change your host file in your computer. When computer is connecting to a website, it first checks its local host file. If the website is in its host file, it does not ask a public domain name server to translate a name into IP address.

Steps

Host file is in the format of IP address – host name. You can edit it with any text editor such as notepad in Windows or Nano in Linux.

Example:

127.0.0.1       localhost

127.0.0.1       example1.com

127.0.0.1      example2.org

Ubuntu and most linux system put the host file is in /etc/hosts;

Windows XP’s host file is in C:\WINDOWS\system32\drivers\etc\hosts

With the sample above, you can your name-based virtual hosts with: www.example1.com and www.example2.org

Reference

Comments are closed.