Configuring Leopard’s Apache to work with all Rewrite Rules

Although there are a few blog posts out there detailing how to enable .htaccess on Mac OSX 10.5. I didn’t find anything that could help me with a problem I had with a specific RewriteRule.

This post isn’t specific to Leopard but maybe useful to users of this OS due to the default values that it’s pre-installed Apache’s httpd.conf comes set with.

Say for SEO reasons you wanted to rewrite




You could use the following rewrite rule:

RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2

In other blogs it will tell you that you will need to change AllowOverride None to AllowOverride All in the <Directory “/Library/Webserver/Documents”> of /private/etc/apache2/httpd.conf and perhaps also in any conf files found in /private/etc/apache2/users. (This is not enabled by default on Leopard).

What they won’t neccesarily tell you is that to get rewrite rules like the above working you need to remove MultiViews from your Options list, leaving you with something like this :

<Directory "/Library/Webserver/Documents">
 Options Indexes FollowSymLinks
 AllowOverride All
 Order allow,deny
 Allow from all

I hope this saves someone the trouble I went through this morning trying to figure it out.

For a quick explanation see the short but sweet Apache Multiviews are evil


Tags: , ,

Wednesday, February 18th, 2009 apache, configuration, osx Comments Off