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 shown 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 or without having it affect your production site (if you already own the domain name and have it hosted elsewhere). The changes only affect your computer as it takes precedence over a normal DNS lookup. Because of this, remember to comment the entries with a # symbol when you’re done or delete them, otherwise, when you go to view your site, what you see may not be what others see because the DNS is pointing to a different IP address.