2815 Views 10 Replies Latest reply: Feb 18, 2008 11:10 PM by Tim Semic
I used vi as root to edit.
I read that you have to change NetInfo's search order, moving the hosts file up in NetInfo's search order in order to have the hosts file block a domain, but they didn't specify which Mac OS version they were referring to, and I thought it better to practice on a test Mac (next week) instead of my MacBook for fear of corrupting the boot cycle. Does that sound necessary, to change the NetInfo search order? Which btw I don't know how to do. I know, rt*m.
If Firefox is not throwing those errors into the console log, does that mean it's a bug in Safari, or would that mean that Firefox is simply not logging that particular error to the console? Safari is being more verbose in debugging?
Thanks for your knowledge.
To change the lookup order (see http://www.macwrite.com/criticalmass/mac-os-x-hosts-regrouped-pf.php - this is an older article, but still works for Tiger):
 From the Terminal, check the current configuration
 If the 'Host Configuration' does not have DNS following FF and NI, then change the configuration file:
sudo mkdir lookupd (make a new /etc/lookupd/ if it doesn't already exist))
ls (check for files, just in case the directory already existed)
cp hosts hosts.original (save the original, if needed)
sudo echo LookupOrder Cache NI FF DNS DS > hosts (make a new host configuration lookup order)
 Restart for any changes to take effect
Thanks for all the help. Red, the instructions you provided allowed me to configure NetInfo Manager to block the domains I was interested in. I used the managed hosts file from accs-net.com as well as adding several domains to it. It proved to be very interesting to load commercial web sites and see the results.
I believe it to be proper to mention here that many sites are solely supported by ad revenue, so when using the knowledge found here you likely would be doing a disservice to web enterprises who are providing you a free service. It is worth thinking about.
Myself I was interested in discovering if blocking domains would eliminate error messages that were getting generated by Safari. I am sad to say that this did not seem to help that problem. The site I am having problems with is myspace.com. Load it and check your console log.
Thank you very much for your help. A very nice tidbit indeed.
I use the hosts file from this site, with the personal webserver configured to show me when something is getting blocked. I realize that some sites depend on ad revenue, but the hosts file usually doesn't block ads that are set in the page source, mostly those that are passed on to some ad server somewhere. If it isn't closely related to what I'm looking at, I am not interested in it anyway.
Here is what I use:
Setting up the webserver, if desired (see http://macmerc.com/sections.php?op=viewarticle&artid=83 ):
 Edit the text file at /etc/httpd/httpd.conf (save the original somewhere)
- look for the line "#ErrorDocument 404 /missing.html"
- remove the comment character "#" and save the new file
 Add the file missing.html to /Library/Webserver/Documents/
- this can be anything, such as a blank HTML document
- for feedback, use something like <i><strike> ad blocked via hosts </strike></i> or a small graphic
 Turn on your personal webserver (System Preferences > Sharing)
- note that this will also allow others to access your /Users/username/Sites folder if your router forwards to it.
Red, I got the 404 working with the strikethrough.
Gnarlodious, I messed with the apple image a bit but then it started doing some funky stuff, like it got very big or stretched out at times depending on the site. I admit I was rushing a bit so I will have to spend some more time on it. When it was working correctly it was pretty cool.
Thanks for sharing that stuff, it's been a pretty fun weekend messing with all that.