howtothings.co.uk
How to block / redirect websites using the Windows host file - Printable Version

+- howtothings.co.uk (https://www.howtothings.co.uk)
+-- Forum: Computing (https://www.howtothings.co.uk/forumdisplay.php?fid=4)
+--- Forum: Operating System and Software Support (https://www.howtothings.co.uk/forumdisplay.php?fid=17)
+--- Thread: How to block / redirect websites using the Windows host file (/showthread.php?tid=975)



How to block / redirect websites using the Windows host file - Mark - 28-08-2011

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.


RE: How to block / redirect websites using the Windows host file - Drumm - 30-08-2011

This can be used for blocking ads as a System-Wide thing. Wink