Friday, December 15, 2006

Enable .htaccess in Mac

It took me a while to figure out why .htaccess is not working on my local web server.
By default, Appach disable .htaccess file in Mac, user who wants to use htaccess should manually modify the httpd.conf file

Here's how to do it (2 main steps)

1. Go to /private/etc/httpd/, then sudo vi httpd.conf, find the line contains "AllowOverride None", replace it with "AllowOverride all". Save the file.

2. Go to /etc/httpd/users/, there you will see all the conf files for all users, edit each of them follow above process. Then restart the web server. And you all set and run.

The sudo command is necessary if you want to have superior privilege to modify a file. Basically what sudo will do, according to wikimeida: "allows users to run programs with the security privileges of another user (normally the system's superuser) in a secure manner", a password must be provided.