Home How-To Block a website on Windows(Hosts file)

Block a website on Windows(Hosts file)

block a website

Ever wondered how a website in a local Internet Cafes is blocked? Ever been a victim of a prank where an irrelevant website is opened when you open Facebook? Stop wondering and read further to know how to block a website.

Why would you want to block a website?

1) You own a business and want to prevent your employees from wasting time. Of course there are different and more secure solutions for these.

2) Protecting your children from certain websites.

3) You have a limited internet connection and want to block certain websites to prevent over downloading.

4) Play a prank on someone.

5) Show people that you can now actually block websites.

How do you block a website?

1) Using hosts file.

2) Using your router

3) Using third party applications

4) Browsers

Block a website using hosts file

Hosts file maps hostnames to IP addressesHosts file has no extension. It is a simple plain text file. Hosts file can be edited using simple text editors like Notepad.

It is located in C:/Windows/System32/Drivers/etc.

Block a website using hosts file

Hosts file location

NOTE: Here I assume that your Windows is installed in C drive. If not, just navigate to the drive letter which contains your Windows Installation.

Let’s block a website using the hosts file.

Navigate to the path mentioned to locate the hosts file.

Just to be on the safer side let’s create a backup of the file. Just copy the file and paste it again. Give whatever name you want.

Now open Notepad as an administrator.

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

You will get something like this. The ‘#’ symbol represents comments. To block a website, just go to the end of the file and in a new line add something like this:

127.0.0.1 www.google.com

Here 127.0.0.1 represents the IP which you want to redirect your to-be-blocked-website. For this example, I am blocking “www.google.com” Sorry Google, no offence to you.

Save the file and you are done. I have installed apache on my localhost and hence I get a result like this when I try to open www.google.com

 

block a website using hosts file

Result

Similarly, you can also play a prank on your friends by simply replacing the “127.0.0.1″ part by any website you want to be displayed when a particular website is opened.

 

Geek, Tech Crazy, Wannabe Entrepreneur, Blogger, Freelancer, Noob

NO COMMENTS

Leave a Reply