This technique can be useful for many purposes, including:
- Develop a serious WordPress site locally, but work with all the correct URLs for the end production domain.
- Test a serious WordPress site on a development server using the correct domain settings, but without the need to resolve DNS publicly. Especially useful when redeveloping an existing live site.
- Migrating a serious WordPress site from an existing domain and hosting to a GridPane server. Allowing you to test the migration before swapping over DNS.
In this article we will use a simple example to go through the process of editing your hosts file to enable this. We've also made video demonstrations of how to do it as well:
In our example, we have a new client who owns their domain at
http://an-example.com and they currently have a coming soon holding page at their old hosting.
We are going to install a development site on a GridPane server, and edit our hosts file to redirect our browser to the GridPane server when visiting the client domain.
In our terminal we can confirm the IP of the server that their domain currently resolves to quite easily by using the ping command.
This command will work for macOS, Windows, and Linux machines.
As we can see, our example clients holding page is currently being hosted on a server with the IP of
Whenever someone on the internet visits their domain,
an-example.com , their DNS records point them to this server.
Step 1. Create a GridPane server.
In my GridPane account I have created a server on which I will install my development site for
an-example.com , as you can see it has the IP address of
You can do so easily by following one of our step by step guides here.
Make a note of your server's IP address.
Step 2. Edit your Hosts file to create the URL redirect
Now open your
host file on your local computer for editing.
On macOS this is located at:
On Windows this is located at:
On Linux this is located at:
Within your hosts file add an entry at the bottom, using the GridPane server IP address you wish to redirect to IP and the live domain you wish to redirect away from. It is usually best to add both the
root domain and the
www host domain.
Make sure that there is only one space or tab between the IP address and the domain.
Save your file and exit.
Step 3. Test that your Hosts URL redirect is working
Prior to testing you should clear your local machine system cache. You can follow these instructions to learn how to do that.
Now that your cache is cleared, you can retest using ping.
If your results show a ping to your GridPane server then the redirect is working.
In this example, the server I want to redirect to has an IP address of
126.96.36.199. We can see from the ping results to the domain
an-example.com is resolving to this IP address, this confirms the redirect is working.
Step 4. Create your development site
Now all we have to do is to create a GridPane WordPress site on the server we provisioned earlier.
We have an easy to follow guide here to show you how to provision a GridPane site.
Step 5. Visit your development site using the redirected URL
All that is left to do now is to visit our development site using the redirected URL.
And instead of seeing the clients holding page, as the rest of the internet does, we will see the development site on our GridPane server.
Step 6. Remove the Hosts Redirect when finished
Don't forget, once you are finished using the hosts redirect you need to remove it from your hosts file.