Redirect and Block URLs with HOSTS File on Windows

bardimin pic

Written by Bardimin

On May 26, 2023
Home » Blogs » Windows » Tips and Tricks » Redirect and Block URLs with HOSTS File on Windows

Redirect and Block URLs you can easily on . Just by adding the IP of a website, you can redirect or block it. Of course, this is very useful to limit the access of your employees or children from accessing websites that you do not allow.

Your PC has hidden files inside Windows folders that you may never use. You the file named HOSTS you can find in the “%windir%/system32/drivers/etc” folder.

hosts file windows

HOSTS file on Windows

You can find the file HOSTS in the Windows operating system in the folder “%windir%/system32/drivers/etc/hosts”. The HOSTS file serves as a repository of hostnames and addresses for local hosts and other hosts on the Internet network, using the Internet (IP).

This file serves as a DNS service for your local and replaces the mappings provided by DNS servers connected to your over the network.

If the DOMAIN is being used by a local host, the computer is a member of the domain, the completion routine will first query the Domain's DNS before performing the lookup in this hosts file. In a local network without a Domain, the completion routine will scan this host file for information regarding the hostname and its corresponding address.

Edit the HOSTS File on Windows

You can use a simple text editor, such as Notepad or Notepad++, to open and modify Windows hosts files.

  1. Open Notepad and run it as administrator.
  2. If the UAC dialog box asks for permission, click the Yes button to allow.
  3. Then click “File > Open” on the Notepad window.
  4. In the “Open” dialog box, change the file type to “All files (*.*)”.
  5. Then navigate to the folder “C:\Windows\System32\drivers\etc” and select the “hosts” file.
  6. Click the Open button to open it.

Redirect Domain URLs using Windows Host File

You can use the hosts file to redirect the website the user is trying to visit. For example, if you don't want users to use or YouTube, you can redirect www. .com and to your company's website. If your company's IP address is 123. 123. 123. 123, on the last line of the hosts file, add a command like the following:

123. 123. 123. 123 www.

123. 123. 123. 123

The line you add will cause someone to go to Facebook or YouTube if they go to Facebook or YouTube to be redirected to your company's website.

Block Domain URLs using Windows Host File

In addition to being used to redirect URLs, you can also block URLs that you don't allow to be accessed. This method is also quite effective to limit your child's access to websites or online games that have a negative impact.

Providing incorrect IP address information will cause the URL to be inaccessible. To do this, IP which is the local IP of your computer is often used. On the last line add: www.

This line will cause the URL of and to be inaccessible. If you try to open it through a browser, you'll see an error message displayed.

Latest Articles

Portable BloatyNosy 0.80 – Debloat and Customize Windows 11

Portable BloatyNosy 0.80 – Debloat and Customize Windows 11

BloatyNosy is a free app that lets you remove the built-in junk apps in Windows that improve your Windows performance. The application is available in portable and installer versions. If you are looking for a free Debloat tool, then you might need to try BloatyNosy...

The sequence of Windows boot processes from zero to ready

The sequence of Windows boot processes from zero to ready

Have you ever wondered how exactly the Windows boot process happens? What processes happen in the background when you press the power button until Windows is ready for you? If yes, then you are in the right place. In this article, Bardimin will explain how all these...

How to Bypass Forgotten BIOS Password

How to Bypass Forgotten BIOS Password

If you have created a BIOS password for your PC/Laptop and forgot it, you may have to send it back to the manufacturer. Don't worry, there are still several methods you can use to bypass or unlock the BIOS password. The BIOS password serves as a form of authentication...

How Proxy Anonymity Works

How Proxy Anonymity Works

The exchange of information on the Internet is carried out on a client-server model. The client sends a request (what files he needs) and the server sends a reply (what files he needs). For close cooperation (full understanding) between the client and the server, the...

How to Create Fake Files of Any Size in Windows

How to Create Fake Files of Any Size in Windows

Do you need a file with a size of 10 MB, 100 MB, 1 GB or 1 TB to test? Follow the following article to create one instantly. You don't need to download files or waste time searching for large files, you can create them easily. Sometimes you need large files quickly to...