Editing The Hosts File For Local Web Development
When I start working on a new site for a client, I like to setup a local subdomain based on the client’s domain like dev.yourdomain.com. Make sure you add this domain to the Settings > General page in WordPress. To do this, you will need to edit the hosts file. Here are some basic directions:
For MacOS
Open Terminal from /applications/Utilities and enter sudo pico /etc/hosts Enter your user password and this will open the hosts file in the Pico editor. You must have an Administrator account.
At the end of the file, add a line: 127.0.0.1 dev.yourdomain.com Save the file and you should now be able to type dev.yourdomain.com into the browser window and it will open the local version of the site.
For Windows
Go to the start menu, right click on Notepad and select More > “Run as administrator”. Copy and paste this path into the File > Open dialog: %SystemRoot%\System32\drivers\etc\hosts
Then add this line at the end of the file: 127.0.0.1 dev.yourdomain.com You should now be able to open your local WordPress domain.