How to Block or Redirect Websites in windows ?

                       The Windows Hosts file is a file that Windows uses to control and map IP addresses. By editing the Hosts file, Windows can be customized to block or redirect specific websites and even protocols that are used by programs and applications.

To get started editing the Windows Hosts file, you first need to locate it.
  1. Open Windows Explorer and click on This PC or My Computer
  2. Double-click on C:\
  3. then the Windows folder and scroll down the page until you reach the System32 folder.
  4. Inside of that folder, open drivers 
  5. and then open etc folder
  6. You’ll now see several files, one of which is hosts.

 

Now, notice that the file type for the hosts file is listed as File. Because there is no default program set to open a file type like this, double clicking the hosts file will simply give you a Windows prompt, asking you which program you would like to use to open the file.

From this prompt, you can choose to edit the hosts file with Notepad. So, simply click to select Notepad and click the OK button. From there, Notepad will launch with the hosts file information.

This way of opening the hosts file was demonstrated to show where the hosts file is actually located within Windows, but you won’t be able to edit it because it’s a system file. In order to edit the file, you have to open Notepad first, running as an Administrator.
Click on Start and type in Notepad, but don’t click on Notepad to open it. Rather, right-click the Notepad listing to bring up the context menu. Select the option Run as Administrator.


With Notepad open, select File > Open. Navigate to C:\Windows\System32\drivers\etc. You will get a blank screen that displays the prompt No items match your search. Change Text Documents (*.txt) to All Files using the drop down menu. Now, you can select the hosts file and click Open.

open_hosts_file

Adding files to the hosts file is very simple. The hosts file uses the format:
IP Address   exampledomain.com
Blocking a website in Windows is as simple as typing the following into the bottom of the hosts file:
127.0.0.1    www.exampledomain.com
So, if I wanted to block a website like www.youtube.com, I could just add the following line:
127.0.0.1    www.youtube.com
 
 
 

What we are actually telling Windows is that the website www.youtube.com should redirect to the IP address 127.0.0.1, which is just the loopback address on our local system. If you don’t have a local website setup on your computer, you’ll just get an error page in your web browser.


For more details you can ask in the comments for more queries ...

No comments:

Post a Comment

If you have any doubts regarding the post. Please let me know.