Enable ModRewrite on OS X
Ivan | Fri, 2005-05-27 12:51If you develop web sites on your Mac you may need Apache's ModRewrite function. In simple terms ModRewrite enables you to change complex urls into simple ones using .htaccess. For example with the help of ModRewrite the urls on this site are in the form of http://creativebits.org/node/title instead of http://creativebits.org/node/?q=title.
If you don't follow you can stop reading and just remember to come back to this post if you ever face the instructions to enable ModRewrite on your OS X installation.
Will helped me to find out how to enable this feature and I thought I should note it down for your reference:
1. Make invisible files visible.
2. Find the file /etc/httpd/httpd.conf and open it in any text editor, for example the free TextWrangler.
3. Change line 406 from AllowOverride None to AllowOverride All.
4. Save. You will need to give your admin password to rewrite this system file.
5. Open System Preferences/ Sharing/ Services and restart Personal Web Sharing.
6. Enjoy.
Commenting on this Blog entry is closed.

What I'd really like is to not have to use http://localhost/~jeff/folder/folder/file.htm when I'm testing locally.
http://folder/folder/file.htm or http://mycomputer/folder... would be nice
I wonder if there's a way to do this?
- Jeff Yamada
www.suborior.com
i don't think you can escape http://localhost/ because that's what defines that the site is hosted locally, but I'm not sure.
If you put your site under /Library/Webserver/Documents/ the url will be http://localhost/ which is quite short I guess.
Sure! Have a look at http://www.sitepoint.com/article/os-x-web-development for example.
- Travholt
http://www.travholt.net/
oh awesome, thats perfecto! thanks!
- Jeff Yamada
www.suborior.com
I'm fairly new to web development but a very useful tool that I've been using so far is Patrick Gibson's Virtual Hosting shell script:
http://patrickgibson.com/utilities/virtualhost/
You'll need to get Apache up and running first but after that it's easy to set up any kind of virtual host. For instance if you're working on www.testsite.com you can set up dev.testsite.com on your local machine and all your relative links/folders will work. Just create folders like testsite.com in your Sites directory and run the script.
Further reading:
http://www.mezzoblue.com/archives/2004/08/05/virtual_host/
http://www.mezzoblue.com/archives/2004/08/05/virtual_host/comments/
I suppose I could turn my linux box into a dns server if I wasn't so lazy. But what I hate most is the ~jeff, localhost is short enough.
- Jeff Yamada
www.suborior.com
You don't need a DNS server - you have NETINFO.
All you really need to do is open your utilities folder (Applications/Utilities)
and open NetInfo Manager. Choose "/" then "machines". Select the "localhost" entry and click the Duplicate icon in the Toobar. Now all you have to do is change "localhost copy" to something else (almost *anything* else!) and it will become a valid domain name recognized by your local computer. You won't even need to reboot, simply save your changes and exit Netinfo Manager and your new hostname will work .
There are a number of ways you could change the default internet files location. One of the best documented is to change the apache config file to use something other than "/Library/WebServer/Documents" as the default location of all html files.
Another possibility is to create a symbolic link to your home folder *within* "/Library/WebServer/Documents".
Open a terminal window and type this:
ln -s /Users/Jeff/Sites /Library/WebServer/Documents/othernamehttp://localhost/~jeff/
will still work but your new name will work too:
http://localhost/othername/
Mark
Thanks!