howtothings.co.uk

Full Version: How to block / redirect websites using the Windows host file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How to block / redirect websites using the Windows host file

Really quick one liner of what a host file is.
The hosts file is a computer file used in an operating system to map hostnames to IP addresses. The hosts file is a plain-text file and is traditionally named hosts.


Steps

1) The file we're looking for is located in C:\Windows\System32\drivers\etc

[Image: how-to-block-websites-using-windows-host-file-01.png]


2) Open the hosts file in Notepad.

[Image: how-to-block-websites-using-windows-host-file-02.png]


3) Your hosts file will look similar to below, (except I have a few other entries in mine that I've blurred out...) simply add the desired website at the bottom, eg.
127.0.0.1 websitehere.com
That will redirect websitehere.com to 127.0.0.1 (localhost)

[Image: how-to-block-websites-using-windows-host-file-03.png]


4) File > Save As > hosts
Make sure All Files is selected (*.*)

[Image: how-to-block-websites-using-windows-host-file-04.png]


5) Try to get to the website...

[Image: how-to-block-websites-using-windows-host-file-05.png]


6) And if we try a ping...

[Image: how-to-block-websites-using-windows-host-file-06.png]


Simple. Remember this only works on the machine that you do it on.
This can be used for blocking ads as a System-Wide thing. Wink