Force DNS on Mac OS X
Update: There's a neat little Mac App called Gasmask that can do this for you with a GUI. Or install from Brew via:
brew cask install gas-mask.
When you go to any website on the Internet, your computer makes a request from a DNS server to what out what IP address the website is living on. This is IP address then cached locally on your computer, which means you can actually overwrite this value. This is especially handy when building a new website and you need to preview the new website before it goes live.
Start by opening up Terminal, and running the command
sudo nano /etc/hosts.
You will need to enter your local computer password.
So, if your new website lives on the server 184.108.40.206, you can add the following line to the bottom of your hosts file:
Pro tip: if you want to compare your old website to your new website, you can be clever and setup your new website on www and leave your old website on non-www (or vice versa). This also depends on if your CMS will let you do this and not try to redirect one to the other.
To quit, press
Ctrl + x then
Now to flush your local DNS enter
And now try opening your website in your browser of choice.
To revert back to what the rest of the world is seeing, just go back into your hosts file as above, and comment out the line with a
# then save and quit again.