Set up Windows Hosts file to redirect to other domain

To redirect example.com to new-example.com on your local machine first open the hosts file in a text editor

%WINDIR%SYSTEM32DRIVERSETCHOSTS

find the IP address of new-example.com (via cmd or https://www.dnswatch.info/) and paste it followed by the example.com domain so it looks like this

12.345.678.910 example.com

Save the file.

Now if you request example.com in your browser you will see the content of the IP 12.345.678.910. If you are using virtual hosts/server blocks you will need to add a host header to new-example.com – namely the host header example.com as this is the domain you are actually using now.

Visiting example.com now will show you the contents of new-example.com.

Leave a Reply

Your email address will not be published. Required fields are marked *