To edit your local “hosts” file, you need to open a text editor such as Notepad or Notepad++ using elevated privileges (i.e Run as administrator).
Start by typing in “note” in the search function of Windows operating system, then right click on the Notepad icon and select “Run as administrator.”
Within Notepad, select File -> Open… and navigate to C:\Windows\System32\drivers\etc. Change the file type drop down list to “All Files”, highlight hosts, and click on the Open button. You should see something similar below.
Add entries line by line using the format IP address -> whitespace -> domain name as indicated above. Remember to save the file (File -> Save) when you’re done. Editing the local “hosts” file allows you to test your site using a domain name without having to purchase one. It takes precedence over a DNS lookup. Because of this, remember to comment the entries with a # symbol when you’re done or delete them, otherwise, when you do purchase a domain name and decide to move hosting, your domain name won’t resolve correctly.