Are you want to redirect or block a website from your computer browser by using hosts file? You cannot easily edit the hosts file since it is protected in windows operating systems. If you try to edit and save the hosts file, you will get error as “You don’t have permission to save in this location” or a “Save as dialog box” appears to save as a different file. Follow the below steps to edit the hosts file in windows.
- Deactivate the antivirus, because some antivirus application might prevent the editing of hosts file from virus or automated software. In windows 10, if you are not using any third party anti virus, then add the hosts file into windows defender exclusion list.
- In windows 8/8.1/10, search for an application “Notepad”. In Windows XP/7, click Start and then click All Programs -> Accessories and choose Notepad.
- Right click on the Notepad application and click Run as Administrator. If it is prompted for and admin password, enter the admin password and click OK or Continue.
- In Notepad, click File and then select Open…
- Browse to the location C:\Windows\System32\drivers\etc and select the hosts file and click Open.
- Now the hosts file is ready for editing. Bring the cursor at the end of the file and click ENTER.
- Add any website address which you want to block in your system. For example, I edit the hosts file to block the website youtube.com.
- Click File and then select Save to save the changes.
Tips and Warnings:
- Don’t make any changes in the default value of the hosts file.
- Once you blocked the website in hosts file, you cannot have access to that website in any of the browser.
- You should have system administrator access to edit the hosts file.
- Once you finish editing the hosts file, activate the antivirus software to prevent your system.