mod_rewrite and Mac OS X Personal Web Sharing

It was very frustrating installing a fresh WordPress on my Mac and finding that the permalinks didn’t work. Turns out the default Apache settings for personal web sharing on OS X disable .htaccess overriding.

sudo mate /etc/httpd/users/yourusername.conf

Now you’ll want to enable Apache to follow symbolic links:

Options Indexes MultiViews FollowSymLinks

And to allow .htaccess overriding:

AllowOverride All

The file should then look like:

<Directory "/Users/yourusername/Sites/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Now in System Preferences, stop and start ‘Personal Web Sharing’. Things should work perfectly now.

2007-05-20 [, , , ]

Comments

  1. Feel stupid for saying this, but I’m very new to Mac’s. I can load the config file but I cant seem to save it. It doesn’t allow me to overwrite it.

    Milos (2007-05-22 @ 08:23)
  2. No need to feel stupid.

    Worth pointing out that I used TextMate (mate) above to modify my file.

    If you prepend the command with sudo, it’ll prompt you for your password, and that’ll then allow you to save the file. If you don’t, and you’re using TextMate, when you go to save the file, a prompt will appear asking you for your password.

    It really depends on what text editor your using, and the command you use in the Terminal to determine when you’re asked for your password.

    David (2007-05-22 @ 09:29)
  3. Please excuse me for replying to a post that is several months old, but if all you want to do is tell your web server to honor the .htaccess files, isn’t adding “AuthConfig” to the “AllowOverride” directive all that is required?

    Are the other options you changed (“Options FollowSymLinks” and “AllowOverride All”) needed to get WordPress working, but not strictly needed for turning on .htaccess files?

    Mike (2007-12-22 @ 19:53)
  4. Found your site via Google search on WordPress, MacOSX and permalinks. Your post solved my problem and saved me countless frustrating hours. Just wanted to say thank you very much!

    Jeff Mackey (2008-01-22 @ 03:37)
  5. Same situation as Jeff Mackey-

    Very useful post. Thank you so much.

    Dan (2008-10-22 @ 23:07)
  6. I love you I think, i’ve been trying to get mod_rewrite to work so I can get up and running with the Zend Framework. Until I came here, there was no luck. Thank you……

    Robert Coster (2009-02-15 @ 15:11)
  7. I bashed against this one for a long time before thinking to search around to see if anyone else had the same problem. Thanks for posting this!

    Tyler (2009-07-08 @ 13:23)
  8. I noticed that folders inside ‘Documents’ cannot be symlinked. Apache seems to ignore these symbolic links. Is there a way to force apache ?

    ps: on Leopard the config file is located at: /etc/apache2/users/yourusername.conf

    thnx!

    Luca (2009-08-09 @ 21:44)

Powered by WP Hashcash