Preview website without IP change

You will find this tutorial about how to set IP address for a domain name (website) manually in hosts file on Windows useful in case you are transferring your domain from one company to another, and the domain is still not pointed to the new hosting IP address. Basically this will allow you to preview website without DNS change.
Another case is if you just want to domain name instead of IP address. We all know that Onlinehowto.net is easiest to be remembered instead of 66.235.184.90 (the IP of the hosting).
Certainly you just can do a joke with someone as setting often used domains like Google.com, Yahoo.com, MSN.com to point to a different IP address.
Here I will tell that this is common trick used by hackers to set Yahoo.com (for example) to point to an IP on a server where exactly the same (as Yahoo’s) web page will be set, but the login form there will just still your password and generate error message line ‘Incorrect password’ and will forward you to the real website.

Anyway, how this can be done? How to preview website without IP change?

This can be done in a file called ‘hosts’, and all Windows OS’ are using it to define certain domains or IP addresses.

The mentioned file is always located into the ‘%SYSTEMROOT%\system32\drivers\etc’ folder. Usually this is ‘C:\WINDOWS\system32\drivers\etc’, but it depends on where your Windows is installed.

For example if you copy the next string:

%SYSTEMROOT%\system32\drivers\etc

And paste it into Windows Explorer like on the next picture, when you hit Enter, you will be directed to the ‘hosts’ file location.

Windows hosts file location

The address will be converted as per the Windows installation location C:\WINDOWS\system32\drivers\etc\.

Hosts file directory content

Now locate the file called ‘hosts’ and open it with your preferred text editor. My advice is to use Notepad to avoid any special characters in this file.

The Windows ‘hosts’ file content by default is:

As you can see this file describe itself, and what it is doing is the mappings of IP addresses to host names.

There is always one record for the local host and as you can see I have set up mywebsite.com to point to a local IP address where I am running Web server.

If you open this domain in your browser, you will see the original website. In my case it will open a page which I am using for creating tutorials.
For example you can see how this trick is used in this tutorial:

Setup a website in IIS on Windows Server

Just add an entry to the hosts file and save it. Then all your browsers will open the new location allowing you to preview website without IP change, and all FTP clients, etc. will open it from the new IP address as well.

Filed Under: Web-hostingWindowsWindows 2003 ServerWindows 7Windows VistaWindows XP

Anthony Gee About the Author: Anthony G. is an IT specialist with more than 9 years of solid working experience in the Web Hosting industry. Currently works as server support administrator, involved in consultative discussions about Web Hosting and server administration. One of the first writers in the Onlinehowto.net website, now writing for Free Tutorials community - he is publishing tutorials and articles for the wide public, as well as specific technical solutions.

Comments (2)

  1. RIGOLLETTO says:

    Cheers mate! I’ve intended to edit the DNS record. Silly ain’t :)

Leave a Reply