etc/host file to redirect websites

Lets say everytime I type site1.com into my address bar I actually want the browser to redirect to google.com.

How would I do that?

Is there a way to modify the etc/host file to accommodate this?

MacPro Quadcore 3GHz, MacBook Pro 2.5GHz, Mac OS X (10.5.3), 5GB Ram, 4GB Ram

Posted on Jun 21, 2008 6:39 PM

Reply
8 replies

Jun 22, 2008 6:25 AM in response to Erik Peterson

Yes. DISCLAIMER>>>> No responsibility taken if you cause problems to your system by messing around with these commands.

Open Terminal.

cd /private/etc
cat hosts


This will display the current contents of the hosts file.

To edit the file:

sudo pico hosts


You will be prompted for an administrator password. You will not see anything as the password is entered.

The pico editor is fairly straightforward. You should add the entry you need after "broadcasthost" and before the ::1 localhost entry.

209.85.173.103 site1.com

Then press CTRL O to save the change and CTRL X to exit.

Done.

Jun 22, 2008 6:16 AM in response to Erik Peterson

site1.com should resolve to 207.210.92.226

So if your browser is pointing site1.com to google there is either an issue with your browsers dns cached or your mac dns cache or your router dns cache or your isp dns cache. Well in a nutshell a dns issue.

You should not need to edit the host file. Try fixing your dns issue.

restart your router.

clear your dns cache on your mac using the terminal command

dscacheutil -flushcache

clear you caches in the preferences of safari or firefox.

Try using http://site1.com again.

Jun 24, 2008 6:31 AM in response to Barney-15E

okay so here's an example of what I have so far.

64.236.24.12 www.google.com google.com google.com/* www.google.com/*

this works fine and takes the user to cnn.com when google is typed in the URL bar in the browser. But what if I want to direct the browser to a specific page on the cnn site. For example: www.cnn.com/HEALTH

Is that possible? I tried this, which doesn't work.

64.236.24.12/HEALTH www.google.com google.com google.com/* www.google.com/*

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

etc/host file to redirect websites

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.