How to redirect URLs?

simX

Unofficial Mac Genius
I was wondering:

Is there any way, via the command line, to permanently redirect certain URLs to other locations/IP addresses? In OS 9, you could accomplish this via a Hosts file, and then tell the TCP/IP preference pane where this file was.

I'm not sure how to do this in Mac OS X. Is there a command to do this in the Terminal?

For example, if I wanted to permanently redirect "www.microsoft.com" to "127.0.0.1" or something, how would I do that?
 
Are you running your own DNS server? If so you could add the microsoft.com zone to your name server and then assign its ip # there...

Or add it to your /etc/host file (well its equivelent in the netinfo database) and assuming your computer is setup to check the hosts file before DNS, then it will map that name to your lo0 ip#

Make sense?
 
yeah, the UNIX /etc/hosts file is only used in single user mode. so use netinfo. it looks something like this:

Code:
niutil -create . /machines/www.microsoft.com
niutil -createprop . /machines/www.microsoft.com ip_address 127.0.0.1
niutil -createprop . /machines/www.microsoft.com serves ./local

you can do it with netinfo manager.app if you like as well. i didn t know that OS9 had a hosts file. i knew that windows did. where does OS9 store its hosts file?

hmm... i just tried this, and its not working. my web browser is still showing me microsofts website. i ll fool around a little more.
 
Back
Top