Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jusacruiser

macrumors 6502
Original poster
Mar 15, 2009
343
14
Palm Beach, Florida
Is there a way I can BLOCK websites on Safari? There are unwanted websites that keep "Cookie-ing" me.......and I want to BLOCK that unwanted audience.

PS: This is not about Parental Controls. I am an adult that just wants to BLOCK unwanted websites.

Thank you!
 
Here are instructions on how to edit the Hosts file: http://www.simplehelp.net/2012/01/25/how-to-edit-the-hosts-file-in-os-x-lion-the-very-easy-way/

The default hosts file will look like this:

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
To block a site, say www.Mackeeper.com, add the following line to the hosts file after the line "255.255.255.255 broadcast host":

0.0.0.0 www.mackeeper.com

so that the hosts file now reads:

##
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcast host
0.0.0.0 www.mackeeper.com
::1 localhost
fe80::1%lo0 localhost​

Save the file then restart the computer (or flush the DNS cache by entering the following line into terminal and hitting return:

sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder; say cache flushed

Restart your browser and you should find the site is now blocked.

You can block as many sites as you want by adding them on separate lines as above.
 
Just use an ad blocker. Host files are not really great for blocking websites, because they requires specific domain names or IP addresses. A program as ubiquitous as MacKeeper is probably using a variety of hostnames.
 
  • Like
Reactions: jusacruiser
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.