Out of the box, the Apache Web server that comes with OS X does not take any notice of .htaccess files (used to set passwords, rewrite URLs, point to custom error pages, etc). It took me a while to figure out how to get them working, so I’ve posted this for Google to soak up. Thanks to Jeremy and MacOSXHints for some pointers along the way.
The first step to getting .htaccess working is to edit your httpd.conf file. Open the Terminal, go to the Apache config directory and open httpd.conf. You will need to supply your admin password:
sudo pico httpd.conf
Use ctrl-w to find ‘Override’. You need the second instance of the term so search twice. You should see:
# This controls which options the .htaccess filesin directories can
# override. Can also be “All”, or any combinationof “Options”, “FileInfo”,
# “AuthConfig”, and “Limit”
Change the setting to AllowOverride All then exit and save. At this point one would think the job is done, but each user has a conf file that would need changing too. Back in the terminal, move into the users directory and get a file listing:
You should see a .conf file for each user on the system. As before, open the conf file for your username and change AllowOverride to AuthConfig:
sudo pico Clagnut.conf
Options Indexes MultiViews
Allow from all
Exit, save and restart Personal Web Sharing in your System Preferences. Your .htaccess files should now work. I don’t know the ins and outs of Apache under OS X so I’m not sure of the security implications here, but if, like me, you only use Personal Web Sharing for local development I don’t see any issues.