Benches macOS

8

etc/host file to redirect websites

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

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?

8 replies

Sign in or join Beachball Help to reply.

  1. 0

    RodneyW

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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.

  2. 0

    Barney-15E

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Tom, they don't have a DNS issue. They actually want to redirect.

    After everything else in the hosts file, add a line that looks like

    208.69.32.230 http://www.site1.com

    The first IP address is where you want to go. The second domain name is where you want to redirect from.

  3. 0

    LarryHN

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    if you sign up with Open DNS you can set up aliases that work that way -
    http://www.opendns.com/features/shortcuts/

    LN

  4. 0

    Erik Peterson

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    isn't there a way to do it on a local machine though also with the etc/host file?

  5. 0

    Tim Haigh

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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.

  6. 0

    Erik Peterson

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I'm sorry maybe I wasn't clear. I was saying what if I want to do it on purpose. How do I make it happen?

  7. 0

    Erik Peterson

    Imported from the Apple Support Forums via the Wayback Machine 🔗

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

    64.236.24.12 http://www.google.com google.com google.com/* http://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: http://www.cnn.com/HEALTH

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

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

  8. 0

    RodneyW

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    This is not something that you can do through the hosts file. The hosts file operates maps IP addresses to domain names. So unless the cnn.com/HEALTH is on a separate IP address to cnn.com you can't use hosts to that part of the job.