It is possible to prevent specific websites from being accessed from your computer. This is useful for parental control and business computers, for example.
If you have children who have reached the age at which they want to use the internet, it is nice to be able to block certain websites. And if you don't want your employees (or yourself) to be distracted by social media websites while working, you can block them too. Also read: What's new in the Windows 10 Anniversary Update?
Every operating system has a HOSTS file, a text document with IP addresses and domain names that is accessed by your computer. By modifying this text document, you can completely block access to certain websites. To edit the file, you must open it as an administrator, as it is a system file.
Customize the HOSTS file
Type the text notepad in the search field next to the start button in Windows 10 and right click on the search result Notepad. Choose Run as administrator. You will probably get a message asking Do you want to allow this app to make changes to your PC? If you agree, the app will open with administrator rights.
Choose File > Open, navigate to C:/Windows/System32/drivers/etc and choose in the drop-down menu above the buttons To open and Cancel the option All files to list all file types contained in the folder. Select the file named hosts and click To open.
The HOSTS file will now be opened with administrator privileges. Place the cursor behind the line 127.0.0.1 localhost or ::1 localhost and press Enter to start a new line. Enter the IP address here 127.0.0.1 followed by a space and the domain name and extension of the website to be blocked. For example, you can block Twitter with the command below:
127.0.0.1 twitter.com
You can add as many websites as you want, each website must be on a new line that starts with 127.0.0.1 and a space. Once you have saved your changes to the HOSTS file, you will no longer be able to visit the added website(s), whichever browser you use.
To remove the block you need to open the HOSTS file again with administrator rights and delete the lines with the websites you want to be able to visit again.