Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

One method of changing the search engine in Safari Web Browsers

If you like the idea of the search bar in the Apple Safari web browser but want to use an alternative search engine (some good reasons why you may want to do this can be seen here), with a little work you can change the search engine it uses. There seem to be only two search engines which can interpret Google's query format:

www.AllTheWeb.com
www.Teoma.com

Firstly, you must obtain the IP address of the relevant host for the search engine you want to use. To find their IP numers, open a terminal window and type nslookup www.searchengine.com. Replace www.searchengine.com with the relevant host listed above for the search engine you want to use. The answer will appear like this:

Server:  yalumba.connect.com.au
Address:  203.8.183.1

Non-authoritative answer:
Name:    www.alltheweb.com
Address:  66.77.74.20

Copy the IP address from the last part (after "Non-authoritative answer:") into the clipboard. Then, type into the terminal (you must have set up a root account) su echo 66.77.74.20 www.google.com >> /etc/hosts followed by exit. Replace 66.77.74.20 with the relevant IP address by pasting the IP address you obtained from the first step.

[robg adds: This method does quite a bit more than changing Safari's search engine -- it basically re-maps google.com to the search engine you specify through the use of the hosts file. This means that any request for google.com is going to get redirected elsewhere. I'm not aware of any specific Safari-only methods of avoiding google, however -- anyone know more on the subject?]

    •    
  • Currently 2.14 / 5
  You rated: 2 / 5 (7 votes cast)
 
[28,787 views]  

One method of changing the search engine in Safari | 17 comments | Create New Account
Click here to return to the 'One method of changing the search engine in Safari' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One method of changing the search engine in Safari
Authored by: wgscott on May 12, '03 10:06:37AM

Thanks for the heads up about Google.

Poindexter may be a convicted felon, but he is hardly an idiot. A friendly relationship is worth far more for both parties than a subpoena.



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: ky11x on May 12, '03 10:45:16AM

I thought /etc/hosts was only used in single-user mode (or if you've made NetInfo search the static files), so why does this work?



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: bongo on May 12, '03 11:48:43AM
Google is not evil. Daniel Brandt is a conspiracy nut with a grudge against Google. Why? Because they refuse to give his webpages the relevance (ie PageRank) he thinks they deserve. Go here for the debunking, and here for a Salon feature on him.

[ Reply to This | # ]
Conspiracy or no, still promotes competition
Authored by: jctull on May 12, '03 12:31:02PM

Perhaps the Google-bashing is a little over the top, but by using other engines, this forces a competitive market. This is the mantra of many Apple fanatics, so this should be easily justified on this basis. I am willing to try alltheweb for a few weeks. It is easy enough to remove one line from my /etc/hosts file.



[ Reply to This | # ]
A little help for a Terminal neophyte?
Authored by: jiclark on May 12, '03 01:54:34PM

I'm getting "etc/hosts: Permission denied" when trying this. I tried both "su echo..." and "sudo echo...", but obviously that's not doing it. Can somebody tell me how to accomplish this? Do I have to log out and back in as root? That seems crazy... Shouldn't "sudo" do it?

TIA,
John-o

---



[ Reply to This | # ]
A little help for a Terminal neophyte?
Authored by: stetner on May 12, '03 07:02:54PM

The problem is that the re-direction of the output happens as you, not root. try:
sudo -s
echo "host xxx.xxx.xxx.xxx" >>/etc/hosts
exit



[ Reply to This | # ]
A little help for a Terminal neophyte?
Authored by: bdm on May 12, '03 10:58:13PM

You can also do it in one line like this:

sudo sh -c "echo something >>somefile"



[ Reply to This | # ]
Got it...
Authored by: jiclark on May 13, '03 12:43:59AM

Thanks, guys, for the more explicit directions.

That's all I needed!

John-o

---



[ Reply to This | # ]
A little help for a Terminal neophyte?
Authored by: a1291762 on May 12, '03 07:21:15PM
I'm getting "etc/hosts: Permission denied" when trying this. I tried both "su echo..." and "sudo echo...", but obviously that's not doing it. Can somebody tell me how to accomplish this? Do I have to log out and back in as root? That seems crazy... Shouldn't "sudo" do it?

I suspect the original post was meant to be:

su
echo 66.77.74.20 www.google.com >> /etc/hosts
exit

I prefer sudo -s rather than su because I don't have to enable the root account.

Your problem is that the >> chars are being interpreted by your shell rather than the privileged subshell.

[ Reply to This | # ]

A little help for a Terminal neophyte?
Authored by: lhatton on May 12, '03 09:50:25PM

I suspect the original post was meant to be:
su
echo 66.77.74.20 www.google.com >> /etc/hosts
exit

I had originally written it that way when I submitted the hint, but for some reason it became changed when it was posted.



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: samsprograms on May 12, '03 09:12:26PM
In terminal I type:

strings /Applications/Safari.app/Contents/MacOS/Safari

and i get a ton of results. I do a search for "Google" and after a bit find the following lines a bit interesting:

http://%@.google.com/%@?q=%@&ie=UTF-8&oe=UTF-8
%@&cat=%@
http://%@.google.com/%@
&cat=
&cat=%@
GoogleSearchChannel
SearchChannel
GoogleSearchChannel.m

I'm 99.9% sure these bits of the source code have to do with the address of the search engine used. I know that %@ is used in Cocoa to replace bits of a string with other things...
The first line seems particularly interesting because when aI do a search for "apple" for example
http://www.google.com/search?q=apple&ie=UTF-8&oe=UTF-8
definitely is
http://%@.google.com/%@?q=%@&ie=UTF-8&oe=UTF-8
with the %@ ts replaced.....

--
Sam

[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: r0adrage on May 14, '03 01:53:32PM

Yup. I changed my "search engine" on safari by editing the binary and replacing that google url with my own. I used "vi" to edit it. First make a backup copy of the Safari executable, then open it up in vi, search for "google" until you get to the url and edit away. Make sure the new url is exactly the same length as the google url (pad it wil meaningless url parameters if needed), or else it will screw up the binary.

When I saved, the file is 1 byte longer than the original, which is puzzling, but it still works, so whatever.

(if that's not enough instructions, you probably shouldn't be messing with it ;)



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: samsprograms on May 14, '03 03:33:53PM

I did it in HexEdit got the same results. I don't know how i would make a longer string or use less %@s though.....



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: Mikey-San on May 13, '03 11:41:55AM

Guh.

This tip is really stupid, heh.

First, it WILL NOT WORK AS WRITTEN. You need to enable the BSD flat files before it'll take effect.

Launch Directory Access and authenticate. Click the "BSD Configuration Files" check box. Now it should work.

Second, why are we modifying /etc/hosts just to change Safari's search engine? There are better ways to do this than to MODIFY A GLOBAL SYSTEM SETTING. /No/ user will be able to get to Google or use Google searches involving the google.com domain name if you do this.

Booooooooo to this hint.



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: Pukamo on Jan 22, '10 10:07:56AM

it doesn't work :o(

it says: su: unknown login: echo

what did I do wrong??



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: Pukamo on Jan 22, '10 10:07:57AM

it doesn't work :o(

it says: su: unknown login: echo

what did I do wrong??



[ Reply to This | # ]
One method of changing the search engine in Safari
Authored by: everkleer80 on Jan 22, '10 11:00:49AM
I think there should be a return between su and echo. But I dont see why sudo echo... (which would be all on one line and wouldn't require the root user being set up) wouldn't work as an alternative.

[ Reply to This | # ]