Using “hosts” file to fake-out local DNS
Here’s the problem:
You have an existing blog at foo.com which you’re moving to WP Engine. So we set up a blog for you at foo.wpengine.com, we migrate the stuff, you make some tweaks, and it’s looking pretty good.
Before you change the DNS, though, you want to be sure it work with the real domain name foo.com, not our foo.wpengine.com name. But how can you do that without actually changing DNS?
Furthermore, if you configure WordPress to run as foo.com, suddenly you won’t be able to log into your administration pages because WordPress will be redirecting all traffic from foo.wpengine.com back to foo.com…. which isn’t switched over yet!
The solution is what’s called “The Etsy-Hosts Trick,” a verbalization of “/etc/hosts” which is what this looks like on Mac OS X and Linux machines, but works equally well on all operating systems. On Windows, it will be in C:\Windows\system32\drivers\etc\hosts.
There’s a file called “hosts” on your local machine which allows you to override DNS. You just add simple lines which mean “I want this domain name to resolve to this IP address.” In our example here, you’d add this line:
199.204.137.111 foo.com
You must restart applications for this to take effect. You don’t need to restart your computer, but you do need to restart e.g. FireFox.
Undoing it is as easy as removing the lines in question and restarting applications again.
For instructions for your particular operating system, and more information about this facility, see this Wikipedia page.
After updating your hosts file you will want to clear the DNS cache resolver of your local machine. To do this, follow the instructions found in this article: Flush DNS