Sometimes you may find you need to access a domain which you have not yet configured public DNS for. You Did you know you can use your computer’s Hosts file to direct it to the correct IP address of the domain you are working on and preview the domain before you update your public DNS? This is a great way to preview a website that's in the process of being built or modified to make sure things work before you update your public DNS.
Modifying Your Hosts File in Windows
The Hosts file in Windows is conveniently located in C:\Windows\System32\drivers\etc\hosts.
You should now be able to access your domain at the IP address you assigned.
Pro Tip: Use vim instead of nano.
Vim is a more powerful command line editor that is much faster than nano once you get the hang of it. To use it for this task type sudo vim /etc/hosts and enter your administrative password if prompted to open the file.
Use the arrow keys to navigate in vim. To insert text press the Insert key (fn+i on Mac). To replace text press Insert twice (fn+i twice on Mac). Press Esc to exit Insert/Replace mode. Type :w and press Return to write changes and :q to quit. :wq writes and quits in the same command. :q! exits without saving.
We recommend testing vim on a test file before using it to edit an important file such as hosts, however once you’ve got some practice with it, you will find you can edit files much faster than you would using nano.
|Content by Label|