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.
Become a Patron of Ask Leo! and go ad-free!
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.
The Hosts file can also be used to create nicknames for links. In my Hosts file I’ve added entries for the IPs to our HTML enabled hardware (like the networked printers) along with their short names; ex.
123.456.789.000 XYZ1 #Laser Printer
So if I need to check out the XYZ1 printer I can simply type “XYZ1” in my browser address bar and the Hosts file redirects me to the correct IP and opens up it’s HTML maintenance screen.
how can i stop downloading from a particular url atomatically?
too much sites are blocked. Whenever I try to access “Required URL is not allowed”. Is there any way I can pass through it?.
Thanks.
not sure about this, but would it not be faster to use “0.0.0.0 badsite.com” ? (the 127.0.0.1 method is also very annoying when running a webserver)
i want to prevent some email from sending to my hotmail email
my email
[Email Address Removed]
That’d be this article: http://ask-leo.com/how_can_i_keep_someone_from_contacting_me_in_email_or_instant_messaging.html
i want to block passport network because i cant go on my msn…okay thankx
No, you don’t. Blocking passport will prevent you from being able to log in. This article has more: http://ask-leo.com/how_do_i_delete_this_microsoft_passport.html
I dunno what happened. Recently, I cannot log into pages such as ebay.com and mail.yahoo.com
Also, I cannot get into any microsoft pages and cannot login to my MSN Messenger.
Would you by any chance know what is going on?
Thx.
My first guess is spyware or virses. Do an up to date scan for both.
Is there anyway can download block porn sex and leave in all the time and don’t delete. For example I was looking for a house in the closure after that they send me porn sex in my computer. How they do that? I did not order anything about porn.
Thank You
Jim
I’m not quite sure what you you are asking, but I’m going to guess that you need to run anti-spyware software http://ask-leo.com/spyware_how_do_i_remove_and_avoid_spyware.html or implement an anti-spam solution http://ask-leo.com/how_do_i_get_rid_of_all_this_spam.html
I found the problem. Alot of the newer spyware removal tools use these things you have mentioned. In my HOSTS file there it was. Somehow entries had gotten int here by the spyware/adware or maybe even from a popup, I’m not sure. Anyway in my HOSTS there were a TON of entries like:
127.0.0.1 http://www.xunleashed.com xunleashed.com xunleashed
127.0.0.1 http://www.google.com google.com google
etc.
Removing those and rebooting fixed me up!
Hi Leo, I’ve been having a (virus) problem with my computer that doesn’t allow me to access Amazon.com, is there any method (or program) that could fix the problem?
I am unable to block this URL (https://www.walmart.com/cservice/ya_index.gsp) by using the method you described above.
Any ideas why this would fail?
Here are the entries that I have tried:
127.0.0.1 http://www.walmart.com/cservice/ya_index.do
127.0.0.1 http://www.walmart.com/cservice/ya_index.gsp
127.0.0.1 https://www.walmart.com/cservice/ya_index.gsp
Ah. I see I chose a bad title for this article.
You can only block entire domains this way. So all of what you have will not work, as you’ve seen. However this:
127.0.0.1 http://www.walmart.com
would block all of http://www.walmart.com
Think “no slashes” when adding entries to hosts.
How we can block cretain url using coding in asp.net?
Is it compussory to make entry in the file
C:\windows\system32\drivers\etc\hosts
of every client machine or make one time entry in server machine
I have got this problem recently, well i cant log into ebay, msn messneger, or hotmail, and even my bank, but when i look in the hosts i have a lot of anti virus sites listed, but they’re still accesable, and i cant find http://www.ebay.co.uk or anything similar. Should i delete the hosts anyway, thanks a lot ive been trying to figure this out all day
Can i do this for many websites? because my brother keeps watching porn… If i can, then how?
hey, i have problems logging into yahoo, my bank, and places that require a username and a password. i dont know why its doing this! What’s wrong?
How can i block myspace from my computer?
Follow the instructions in the article you just commented on :-).
How can I block http://www.msn.com? I followed the directions above but it seems that msn.com is not blockable.
Thanks
I tried adding a list at the end. but the site was not blocked…what do i do…
ex : 127.0.0.1 http://www.google.com
plz do help
I have two systems. One of them is fixed by the above solution but in my other system i couldn’t find the “c:\windows\system32\drivers\etc\hosts”. As the folder “system32” itself is not there. i have windows XP SP2 installed. Could you kindly guide me with asolution.
if you’re using Windows Explorer to locate the file, make sure that it’s configured to show system and hidden files. This article happens to show how to set that (in addition to a couple of other things: http://ask-leo.com/how_do_i_get_windows_explorer_to_display_details_by_default.html)
i tried deleting the anti virus sites in my hosts file but it wouldnt let me. the computer kept saving the deleted version as another file and would not let me overwrite the hosts file, i think i am missing somthing plz help this sucks!!
Thank you man . this solved my problem with virus
Thank You! I can now block that virus pit myspace.com from my son’s computer. Everytime he was on that site for more than ten minutes there would inevitably be a virus warning. I was getting tired of cleaning up after it.
Hi, could you please tell me how to block a URL on a Mac? Thanks,
Is there a way to do the opposite? To allow only one site and block all others without manually typing in every one to block?
Mac: I believe the file is the same, only located in /etc and called either hosts or localhosts.
I cannot use hotmail via the internet explorer but I can if i go thru AOL. How do I fix that? Thanks
Thank you so much, really helped with my virus problem (sites blocked that I had no idea about).
i’m trying to block myspace but i can’t find the IP address… what am i doing wrong? or at least how do i find it?
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.
But I found when I did this and only find the host file is 1k and cant’ open it, please tell me how to open it in notepad, Thanks.
I’ve followed all the instructions in the article but it still won’t block the websites. :-( Is this specific for IE? I use Firefox but from what I understand, that wouldn’t make much of a difference, would it?
I have checked c:\windows\system32\drivers\etc\hosts and it is clean however I cannot access my website from 4 different computers one of which is not networked. This denial took place progressivly over 2 days and I suspect malicious code has been installed somwhere. Any idea where to look next.
How do we open a block URL? I am working in Gulf & They block most of the site.
it blocks the parent url correct? meaning i should expect both http://www.blocked.com and http://www.blocked.com/leftframe.htm to be blocked under this right?
cheers
Yes.
But remember that you probably need to block both “badsite.com” and “www.badsite.com”
I’ve done everything as instructed, tried both “badsite.com” and “www.badsite.com”, rebooted the machine, etc – the website is still as accessible as ever. Any more advice?
Oh, also there are many entries in the system32 hosts document but they aren’t (to my limited knowledge) exclusively antivirus sites. For example “www.mysearch.com” and “www.findology.mail.everyone.net”.
Many Thanks.
I added the lines:
127.0.0.1 servedby.advertising.com
127.0.0.1 cdn.fastclick.net
127.0.0.1 media.fastclick.net
127.0.0.1 m.uk.2mdn.net
They did nothing?!? why’s that?
I found a similar website instructing how to use the HOST page to block websites, but this one says to use the next # in the sequence. like 127.0.0.2 and so on down through the numbers. one for each site requested to block.
is this necessary or can they all be listed under 127.0.0.1?
I actually don’t know why you’d want different numbers .. unless you were trying to trace things somehow. Setting them all to 127.0.0.1 is just fine.
I have noticed that some sites dont get blocked because they use subdomains that actually use a different IP address, so I ping the subdomain, then block that ip address instead of the domain.
how can i overwrite hosts file??? it seems that its not overwritable when i changed something and save it as the same filename???
there are two problems…
1. I did as u suggested but its not blocking any site.
2. What to do to allow a few sites and block all others.
will it be possible for you to answer me thru mail please.
thanks
regards
avi
is there a way to block all site except for mail servers? like mail.yahoo.com tnx in advance
If I create an entry in the Host file to send http://www.myspace.com back to the loopback address will it work on all the portions of the website? Meaning, if I link to or type in http://www.myspace.com/sixfootdeathtrap (My former band) will it skip past the Host file entry since it just says myspace.com and allow access to the page?
—–BEGIN PGP SIGNED MESSAGE—–
Hash: SHA1
You need two entries in hosts:
127.0.0.1 myspace.com
127.0.0.1 http://www.myspace.com
The key is that “myspace.com” and “www.myspace.com” are two different web
domains. Since they both get you to the same place you need to deal with both
of them.
What *follows* the “myspace.com” doesn’t matter.
Leo
—–BEGIN PGP SIGNATURE—–
Version: GnuPG v1.4.6 (MingW32)
iD8DBQFGFBZuCMEe9B/8oqERAtRNAJ9V61C2GkjlQmaqfQQ2tFiozzKW7wCfVYMJ
CPmwPwb14w6uWN17gtMB4kM=
=+XYw
—–END PGP SIGNATURE—–
if you want to block and unblock websites plz go to freedwonloadcenter.com and put words ” Arm Aduld Filter 1.0 freeware ” and click and you will find freeware software and download it free and use it.
Thanx for help with restricting sites in IE…btw: my name is also Leo… :)
I cant seem to make it work either. I rebooted and cleared the cache and such…
Hey this is so cool! I just blocked that very annoying poker ad on the side of bitComet.
And how would i unblock certain URL’s?
im confused
this **** sucks it does not work 100% what the hell is wrong with this host file, in all serious I’m frustrated to DEATH. half the sites are still unblocked.
# 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
127.0.0.1 http://www.gaiaonline.com
127.0.0.1 gaiaonline.com
127.0.0.1 http://www.rs2cheating.com
127.0.0.1 rs2cheating.com
127.0.0.1 http://www.runescape.com
127.0.0.1 runescape.com
127.0.0.1 avatarsave.gaiaonline.com
127.0.0.1 myspace.com
127.0.0.1 http://www.myspace.com
Hey Thanks for the useful info.
This dosen’t work. I have tried. Whats the prob ?
You have probably set your browser to not check for new versions of the page every time, thus it uses whatever is in your cache, in temporary internet files. Clear your temporary internet files, or change that setting to check for new version everytime.
Tools > Internet Options > General tab – Browsing history > Settings > pick “Every time I visit the page”
the guardware’s iShield / iShield Plus is very good. try it out
Here is how to do it right, look closely at the incrementation of every line:
127.0.0.1 localhost
127.0.0.2 http://www.gaiaonline.com
127.0.0.3 gaiaonline.com
127.0.0.4 http://www.rs2cheating.com
127.0.0.5 rs2cheating.com
127.0.0.6 http://www.runescape.com
127.0.0.7 runescape.com
127.0.0.8 avatarsave.gaiaonline.com
127.0.0.9 myspace.com
127.0.0.10 http://www.myspace.com
thank u
Oh! Windows defender keeps saying that the host file have been changed, and i can see lots of bad names. BUT IS IT FOR BLOCKING??? because i deny them all the time
It is a good idea. Thanks
great but how to i get to this..c:\windows\system32\drivers\etc\hosts
thx
Works fine for me!!!!
I added ad.doubleclick.com and ads.cnn.com.
Now when I go to cnn.com, my browser clicks about 6 times after initial pageload, but the little “advertisment” square in middle/right part of screen IS BLANK!!!!!!!!!!!!!!!!!
ok nice.! but.
how if the donain has sub domains.
eg blocked badsite.com but they have subdomain adult.badsite.com
ok i coud put that name to the list but the domain coud have hundred of sub names and building up new ones.
so is ther a wildcard i coud use or something.
tryed *.badsite.com and #.badsite.com but no luck.
This isn’t URL blocking. A URL refers to a complete host name/file name pairing. What you describe is properly referred to as HOST blocking. If I wanted to block ONE PAGE or more likely a SCRIPT from a host (a URL) – I could not do it using the HOSTS file and leave the rest of the site open.
—–BEGIN PGP SIGNED MESSAGE—–
Hash: SHA1
I sit corrected – you’re quite right.
Leo
—–BEGIN PGP SIGNATURE—–
Version: GnuPG v1.4.7 (MingW32)
iD8DBQFHlqAyCMEe9B/8oqERAoaoAJ0VjBWk1cPUhHyrih/rWGxTQOTAKQCgjy8m
W7+/fEtW7sw2gNxHsQfIVig=
=6Lm3
—–END PGP SIGNATURE—–
please help. my bf keeps screwing around with settings and what not on my comp. My internet works good enough for me but when i click on hotmail on the msn homepage to get to my email as usual, it just goes to a blank white page and does nothing.a long address goes into my address bar and thats it.nothing.if someone knows how i can fix this, please let me know somehow. Im not sure of who im even writing this to.?please.
i tried blocking some sites on the hosts on my computer but it didnt work.i restart my computer but still i can access to that site?why is that?is there any other way to block sites aside blocking them on the host?thanks
I ahve been trying the above method but it didint work there are number of escape route. Can you tell me how to block all the instances of the web page
This Solution works I promise I recently Applied it to my computer to keep my daughter off myspace.com. Remember you have to line it up exactly as it appears in the host file EX. 127.0.0.1 http://www.sitename.com. I promise you this works. Now the only thing is It does not block you from putting the IP adress in to the run slot to overide. this is the only way around this once you add this site to the host file. If your child is not a computer geek there is no way around it.
hey thanks alot for the help i am using this to try and stop CID: pop-ups firstly i this the correct thing to do secondly will itblock all the CID: pop-ups?
how can I block my kids from accessing myspace and all it’s subcomponients from my computer, ie. home.myspace.com/comment.myspace.com, etc.
Thanks
I am able to get into my mail address but not able to read anything as it wont let me readd into
any of my inbox,draft,sent etc.
i just get the pop up saying comp had encountered a problem and given a choice to send report or not.
after clicking on any, then i looses my site and have to try to log in again…
Please help
Good Day,
Is there a way that you can block all the URL and allow a certain website only ?
Thank You
— dennis
this method pretty much works, but only providing that the end user isn’t that innept in the innards of “stuff that is crammed in the computer”. Since there are WAYS to get around this.
A more appropriate solution would be to either: write, or find someone that does programming and have them write it for you, that does something similiar *like* this, but a little bit more advanced that involves packet sniffing techniques and does a stealth comparision test on the information passing through the TCP/IP connection. You simply strip out a section of the packets then reassemble them into a string, then test that string against an existing datafile that you specify (either a host, or a specific url). If found then add a section of code that locates the current active window handle (parent handle-your browser), then locates the control handle for url addresses typed or entered, then send a faked click hit on the goto button or whatever its control is labeled or handle is known as. Works great at catching personnel wasting company time & money. This method works down at the hardware level since its capturing raw packets which the browser doesn’t control nor see. But all this needs to be done in stealth, or it can be defeated as well. This might be a little bit more than most people could take on as a small project, so either look for something that is already existing and written, or find you a programmer that takes on simple stuff like this and have them write it for you. And sorry, no, i won’t write this for you. I’ve already got ALOT more than what I can handle at the moment as projects goes.
Leo, your solution did not work at all. I can still access the site in question :(
I open the host in notepad, find where it says 127.0.0.1 localhost, then make a new line and type in 127.0.0.1 http://www.badsitesname.com saves and exits. But I still can access the site! Please help :(
with my IE 7.0 it still can acces the site.
diffrent with my firefox 3.0 it can’t
My Question is is this for IE article or for the others browser also. TQ
But Thx for the tips.
Make sure that you’re NOT entering
127.0.0.1 http://www.badsitesname.com/
but that you ARE entering
127.0.0.1 http://www.badsitesname.com
In fact, to be safe(r), might wanna make it
127.0.0.1 badsitesname.com http://www.badsitesname.com
Thanks,this really helps.
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???
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
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.
Is it possible to block soem pages , but not whole site?
E.g block domain/badPage.htm but leave allowed domain/GoodPage.htm?
06-Dec-2008
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.
21-Jan-2009
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?
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) http://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, http://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.
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?
20-Sep-2009
# 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
http://ripie6.com/
I am adding this post as the web address above didn’t show up. trying again
I am trying to block craigslist from my children on my computer, I tried the 127.0.0.1 and added craigslist to the end of the 127.0.0.1 all 3 ways “www.craigslist.org,craigslist.org,craiglist” but using google search I am still able to get to the website.please help-how can I block this website when using google,msn or anyother search engine.
I having problems with going to youtube everytime i go to the website it is overtaken by another xtremetop100.com is the website that is replacing it and i have no idea why.
Is there a way to block a range of ip address’s in IE 8
I,m having problems with my hotmail account….i,m starting 2 received strange mails from adult sites that I have never been before and they just won,t stop!!! I don,t know if someone played a joke on me with that but I want them OUT OF MY MAIL
04-Oct-2010
Well…you can just use a web filter..e.g.: homeguard:
http://veridium.net
Your navagination bar is stretching the page out ,but this only happens in chrome. In firefox it looks alright though.. At first I thought that it was just something wrong with my browser. Just letting you know so you can fix it :)
02-Feb-2011
Actually, editing hosts file affects all web browsers, not only IE. So if you want to block some adresses only in IE, you should use some other way.
—————————————-
art thesis
Thanks a lot for the blog article.Really thank you! Much obliged.
Dear Leo, beautiful Yr website & thanks for yr help!!
I’ve been reading all of 102 posts, but still could you explane something better about:
1) if we find written “127.0.0.1 localhost”, shall we delete the word “localhost” or let it there and simply to write addresses after that?
2) In my host file I’ve found this (se below): what the 2nd line is? Since I have many troubles like entering in my HotMail account, ecc., could it be a virus harassing my computer? Or could it be something created by a IP changer program, ad Jdownloader? Anyway, should I delete it or not?
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
3) What happen if we delete “127.0.0.1” and write instead “127.0.0.2”, or similar? Is this a way to get a new IP? Does it works?
I HOPE YOU’LL REPLY. If not, replies from other helpers are welcome, too! Venetian girl :) God bless you, Leo! ;)
23-Sep-2011
Dear Leo, thanks so much for yr reply! I was afraid do not get it :) I’ve understood, thanks!
I made a mistake anyway, because yesterday I tried to create the automatic IP change of Jdownloader, but there was not info about how to go on with the process, so I stoped that and… since that moment my downloads with any download tood is SOOO slow, quite still! I think something ruined my connection/IP (I use a public wifi connection with my own comp)… Anyway, I’ll find the solution, I hope…
Thank you so much for your free, friendly help :)
I just wanted to say I enjoyed your posting. Would you mind if I quote a few of these articles on my site as long as I provide credit and sources back to your blog? My website is in the exact same niche as this site and I’m sure my followers would truly benefit from some of the content and information you present here. Cheers!
14-Apr-2012
i have entered my wrong password many times and my hotmail is closed so i can’t open it now.
please help me , with thanks
@Amer,
Try this article:
What are my Lost Hotmail Account and Password Recovery Options?