Ask Leo! by Leo A. Notenboom

Is there a way to block certain URL's in IE?

Search First! Then browse: Categories | Full Archive | By Date | Newsletter

Home » Networking

Summary: There are ways to block URLs in IE, but doing so will block them from all other programs as well.

Is there a way to block certain URL's in IE?

Actually, there is, yes. But when you do it, you'll be blocking them in IE and any other program that might attempt to access them.

Interestingly enough, it's the same technique that some viruses use to block you from getting to anti-virus sites.

Normally Windows uses what's called DNS to map a domain name, such as "microsoft.com" to an IP address, like "207.46.130.108". It's easier for you and me to remember domain names, and this also allows the domain name owners to change their internet addresses at will.

The "hosts" file is a plain text file that can contain overrides to DNS. In it you can hard-code the IP addresses that domain names will map to. Normally, it's not used at all, but it's a great opportunity to block access to domains you don't want accidental access to.

The hosts file is typically found in "c:\windows\system32\drivers\etc\hosts". You may need to change the file's read-only attribute so that you can make changes. Open it in notepad.

You should notice an entry like this:

127.0.0.1 localhost

That defines the IP address of "localhost" to be 127.0.0.1, which by definition is your own machine.

To block a site, just add a similar entry to the end of the file. For example:

127.0.0.1 www.badsite.com

Now "www.badsite.com" is mapped to your machine. Since you're probably not running a web server, any attempt to visit that site using a browser will fail. In fact, ANY attempt to use "www.badsite.com" will get directed to your own machine and will typically fail.

The only caveat is that addresses are often cached by the software. That means you may need to exit all instances of your browser, for example, before the blockage becomes apparent. In the worst case, reboot, and it should take effect.

By the way, if you open the hosts file and find a long list of what look like anti-virus site domains, you've been infected by a virus and probably want to scan as soon as possible. And feel free to delete those entries from the file.

Article C2110 - July 10, 2004

Helpful? Get new articles weekly by email in my FREE newsletter!

Your Name:
Your Email:


Why Subscribe?

Recent Comments
93 Comments

Thanks,this really helps.

Posted by: ibzy55@yahoo.co.uk at September 30, 2008 3:41 PM

I think someone is blocking me from being on popular site called tribe.com Is this possible to block my ip address from the whole tribe network???

Posted by: angie at October 7, 2008 6:28 AM

Dear brothers;

i need help , i am working in a bank, in afghanistan, any site i am entering is blocked , i am tired of it, is there any way to access the websites that are blocked by the servers.

[personal address removed]

my email write me the solution plz.

thanks

Posted by: Mustafa at November 22, 2008 10:56 PM

how do I change the read only attributes when I try to save it, it says that it cannot and to make sure the path and file name are correct please help me.

Posted by: Kristin at December 4, 2008 11:57 PM

Is it possible to block soem pages , but not whole site?
E.g block domain/badPage.htm but leave allowed domain/GoodPage.htm?

Not easily, no.
- Leo
06-Dec-2008

Posted by: Michael Freidgeim at December 6, 2008 3:17 AM

I keep getting some unwanted e-mails ,I keep blocking and deleting these mails and addrreses. But I noticed that everytime they use a new address , is there anything I can do about this.

Regards.

That's the definition of SPAM. Try this article: How do I get rid of all this spam?!?!
- Leo
21-Jan-2009
Posted by: Erik at January 20, 2009 6:04 PM

whenever i try to save the file it windows says it cannot create the file, and to make sure the path and file name are correct, i checked, both were.

i also checked to make sure that it wasnt read only, and it was not, so im not sure of the problem.

help?

Posted by: samma at August 4, 2009 1:25 AM

Leo is perfectly correct all he has said here. But who are saying its not working make sure you typed 127.0.0.1 (spance here) www.badsitename.com.
Without space it won't work.

And the message it cannot create the file, and to make sure the path and file name are correct: is shown because the file hosts is being accessed by another process (may be your antivirus). If so then first disable antivirus then try to change the file again. Hope, you'll able to do this time.

But Leo I need a little bit more expand with that. Suppose I want to redirect all subdomains of the site badsitename.com. e.g, blog.badsitename.com, www.badsitename.com. webmail.badsite.com etc. Then without writing all these can I do this just by this kind of trick:
127.0.0.1 *.badsitename.com

Another issue: If someone tries with the ip address of the badsitename.com he can easily enter the site because we are redirecting during domain name to ip conversion processing. What is solution if I also want to redirect if someone tries with the ip address of the site.

Thanks leo very much.
Thanks Leo.

My understanding is that wildcards (*) do not work in the hosts file.

For sites that have dedicated servers, there's no way to block direct-IP address. The good news is that many sites are on shared hosting, which means that an IP address alone is not enough. More here: Why doesn't accessing a site by its IP address work?

Leo
20-Sep-2009


Posted by: rootkit at September 20, 2009 12:05 AM

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost
here my file but I don't see the site that I want to block.

Also this started because whenever I try and goto a particular site it loads it for a second and then redirects me here which I am hoping if I block it will stop this nasty little redirection. Any other assistance would be gratefully accepted. Thanks

Posted by: Greg at September 21, 2009 9:25 PM

http://ripie6.com/
I am adding this post as the web address above didn't show up. trying again

Posted by: Greg at September 21, 2009 9:26 PM

Post a comment on "Is there a way to block certain URL's in IE?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

  • Read the article at the top of this page. If your comment shows you didn't, it'll be deleted and ignored.

  • Comment only on this article. Use the Google search box at the top of the page if you have a question about something else.

  • Don't include personal information in the comment. No email addresses. No phone numbers. No physical addresses.

  • Don't spam. Excessive links to unrelated sites within a comment or across multiple comments will cause all such comments to be removed.

  • Don't ask me to recover lost passwords or hacked accounts. I can't, and those comments will be deleted.

  • I can't respond to every comment. And I can't vouch for the accuracy of others who do.

Please wait. Your comment is being processed ...


Question? Ask Leo!