If you would like to set up pre-published viewing for your website before you officially point your domain to your new hosting provider, you will need to modify the host file on your computer. This is the recommended method for pre-published viewing.
Modify Your Host File on Mac OS
Follow the instructions below to modify your host file on a Mac. This method applies to any version of Mac OS X or MacOS.
In Spotlight Search, type in Terminal and press Enter, or go to Applications > Utilities in Finder and open Terminal.app.
In the terminal, enter the following command (without quotes), then press Enter:
sudo nano /private/etc/hosts
You might be prompted to enter your computer login password. Type your computer password into the terminal and press Enter. Note that the terminal does not display any characters as you type, so take care to type your password correctly.
The terminal should now display your host file. Use the arrow keys on your keyboard to scroll to the end of the file, and below the existing text, enter your site's target IP address followed by a space and <yourdomain.com>, another space, and <www.yourdomain.com>. It should look like the example below, replaced with your IP address and domain:
220.127.116.11 yourdomain.com www.yourdomain.com
When you’ve finished entering your IP address and domain (with and without the ‘www’), overwrite the file by pressing CTRL + O on your keyboard, and then Enter to save. Then press CTRL + X to exit the editor and return to the terminal.
When you have returned to the terminal, enter the following command (without quotes) and press Enter:
This command clears your DNS cache which allows your new settings to take effect. After you enter this command, clear the cache from your web browser, then restart the browser. You should now be able to access your website by entering your domain into the URL field. Note that this website installation is accessible only to you, because you’ve modified your host file. When you are ready to officially publish your website, you must update your DNS records to make your site publicly available.
Removing Your Host Entry
When you are ready to update your DNS records and make your StudioPress Site publicly available, you should remove your host entry so that you are able to test your DNS settings and spot any issues with the process.
To remove your host entry, follow Steps 1 and 2 above to open your host file in the Terminal, then use the arrow keys to scroll down and delete the entry you made for your StudioPress Sites website. Press CTRL + O on your keyboard to overwrite the file and then Enter to save. Press CTRL + X to exit the editor, then close the terminal. Your host file is now back to normal and you can begin the DNS mapping process.