Block Websites via Hosts File
The hosts file is an important system file for resolving IP addresses. Every IP address that you add to the hosts file will resolve to the domain that is listed for that IP. So, if you’re adding the IP address of a website and another domain, you can effectively block websites. All you need to know is where the hosts file is located and the IP address of the website that you want to block.
The location of the hosts file in Windows 7 is: C:\Windows\System32\drivers\etc
Sidenote: In Windows 95, 98, ME the location is: %WinDir%\
To get the IP address of a website, click on Start, enter cmd and hit enter. Enter ping domain.com (replace domain.com with the domain of the website that you want to block). Copy the address you are receiving a response from.
Hosts file example:
Here’s an example how you would block the website via the hosts file:
74.125.45.100 localhost
This would resolve the IP address of Youtube.com to localhost (which has the address 127.0.0.1).
Important: The IP address will not start resolving immediately, you will first have to reboot your PC. You can still access the blocked website when you click on a link. If you want to completely block access to the website, you should try the Firefox addon BlockSite or the Internet Explorer Content Advisor (for links and explanations see below).
If you’re getting an error when you try to save the hosts file, you should read this: Hosts file access denied
How to block websites in Firefox
Firefox also has a nice extension that allows you to block websites and remove all links to the website from other websites. You can download the extension BlockSite over at https://addons.mozilla.org/
How to block websites in Internet Explorer
1. Step Start the Internet Explorer, go to Tools / Internet Options
2. Step Go to the tab Content.
3. Step At the bottom click on Enable to activate the Content Advisor.
4. Step Next, click on Settings and go the tab Approved Websites and add all sites that you want to block.
You can block all subdomains of a website by entering *. in front of the domain. So if you want to block all sites of google.com, simply enter *.google.com
5. StepBack on the General tab, check the option Users can see websites that have no ratings
6. StepClick on Create password to set a password for editing websites and to disable the Content Advisor again.