Click here to Skip to main content
Click here to Skip to main content
Go to top

Blocking Particular Website in Computer

, 11 Sep 2012
Rate this:
Please Sign up or sign in to vote.
How can I block some website permanently like (facebook.com) and more social site on my employees computers

Introduction

Many times while answering on community forums and surfing on the Internet, I have a question about how to block a particular website on the computer. This is from sensible parents who care for their child, administrators who manage Office and Office Network at work. This is really a great problem in case of social networking sites. I have searched and tried almost all softwares, Windows Features like parental security, content adviser, etc. But some of them throw annoying messages or some pop-ups and graphical disturbance.

So finally, I tried hosts file which is a threat according to Microsoft Security Essential. But it does not harm your system in any manner and does not install any third party software on the computer.

Background

I have tried to block access to those sites from Router Configuration, but at some point I need to enable them in particular PCs which is really difficult and a hard task. So I am here to tell you the method of blocking websites using hosts file.

How to Change Setting

I am going to tell you about changing the setting. To do so:

  • Open Notepad with Administrator Rights.
  • Ctrl+O to Open File. Choose File Path Below.
  • Windir:(C: )\Windows\System32\drivers\etc
  • Change File Type to All Files from Right Bottom Corner.
  • Choose hosts file and open it.
  • You will see the below lines at the end of the page:
    #127.0.0.1       localhost
    #::1             localhost

    Now just add this code to block a website named domainname.com and an IP address.

    Using IPv4:

    127.0.0.1 www.domainname.com
    
    127.0.0.1 domainname.com
    127.0.0.1 258.258.258.258 (Sample IP - So Invalid)

    Using IPv6:

    ::1 www.domainname.com
    ::1 domainname.com
    ::1 258.258.258.258 (Sample IP - Used Invalid)

    Now save this file. If you are using antivirus, this may disinfect it, so disable Real Time Protection for some time and after saving changes, enable those settings of antivirus.

You are done, open any browser and enter the blocked URL in address bar and click navigate button. See the result.

Note

This will block access to the mentioned website in your system in all applications. So you don't need to worry about Browsers, Chatting Applications, Desktop Programs, even a link to Website or IP address.
You have to change some setting in individual PCs for doing so.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

John Bhatt
Software Developer (Senior) P.Yar.B Complex
Nepal Nepal
John Bhatt is an IT Professional having interest in Web technology. He is Web Designer, Developer, Software Developer, Blogger and Technology Geek. Currently he writes his Blogs at Blog of P.Yar.B and various other Sites. He is Main author and founder of Download Center.
Contact Him at : Facebook | Twitter | Website.
Follow on   Twitter   Google+

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 11 Sep 2012
Article Copyright 2012 by John Bhatt
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid