Enable mod_rewrite on OS X 10.4 (Tiger)

Tiger has introduced a new super-confusion level to the stock configuration of Apache. In addition to the httpd.conf file in the /etc/httpd directory, there’s now a new users directory as well. That directory holds unique config files for each user of the machine. So, if you were to enable mod_rewrite or AllowOverrides in httpd.conf, you may find that it doesn’t quite cut the mustard in your personal Sites directory. Let’s take a look:

To enable mod_rewrite:

  1. Open /etc/httpd/httpd.conf
    (I highly recommend TextMate – from the command line you can simply type this:
    $ mate /etc/httpd/httpd.conf
    or use the old standards: vi, vim, whathaveyou)
  2. Go to line 223 (if your config file just so happens to jive with mine) and uncomment the following line:
    LoadModule rewrite_module libexec/httpd/mod_rewrite.so
    (mind the wrap)
  3. Go to line 267 and uncomment the following line:
    AddModule mod_rewrite.c
  4. Scroll down to line 408 and change the line to read:
    AllowOverride All
    (Some server admins will tell you this may not be the best idea for hosting a live site, but I’m assuming you’re using this for local development only, right?)
  5. Uncomment line 454:
    AccessFileName .htaccess
  6. Restart Apache:
    $ sudo apachectl restart

At this point you should have mod_rewrite happily fixing your ugly URL’s in the /Library/WebServer/Documents directory, but it’s not working in your /Users/you/Sites directory. What gives? Here’s the trick:

  1. Open the yourname.conf file in the /etc/httpd/users folder.
  2. Change the first two lines to this:
    Options All
    AllowOverride All
  3. Give Apache another bounce:
    $ sudo apachectl restart

You should now be seeing friendly url’s in your very own Sites directory.

    • Jon
    • December 26th, 2005

    I followed these instructions to the letter (thanks for posting them), and I’m now trying to get friendly URLs to work for this WordPress plug-in:


    The .htaccess file in the relevant directory now contains:

    # BEGIN FAlbum

    RewriteEngine On
    RewriteRule ^photos/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?([^/]*)?/?$ /~jonzahlaway/zahlaway/wp-content/plugins/falbum/falbum-wp.php?$1=$2&$3=$4&$5=$6&$7=$8 [QSA,L]

    # END FAlbum

    Nonetheless, when I point my browser to /~jonzahlaway/zahlaway/photos/, I’m getting a 404, and when I point to /~jonzahlaway/zahlaway/wp-content/plugins/falbum/ it loads fine. Anyone know what the problem might be?

    • robert
    • March 24th, 2006

    Thank you SOOOO much! Over at drupal.org no one (including me) has ever heard of yourname.conf or so it seems.

  1. Jon,

    I’m doing the same that you are doing (wordpress on mac), however, i put my wordpress in the main server page, so there is no ~/username, its in domain root. Oh, i also made one of the domains i dont ues point to my home machine. However, i’m sure somehow, it could work with localhost.

    Eitherways, i’m suck too, i’m getting a 404, No idea where to go!.

  2. After lots of pain, I’ve found a solution that works for me on osx 10.3.9

    In userName.conf:

    DocumentRoot /Users/userName/Sites/

    Options Indexes MultiViews
    AllowOverride All AuthConfig
    Order allow,deny
    Allow from all

    In a .htaccess file located in /Users/userName/Sites/:

    Options FollowSymlinks
    RewriteEngine on

    In all .htaccess files located in every site I want to mod_rewrite (all placed into main Sites folder, of course):

    Options FollowSymlinks
    RewriteEngine on

    Of course you have to write some rules in your .htaccess files for it to work 8)

    Regards from Spain

  3. Oh, oh, all tags are gone, I think I should have put some code tag or something. I’ll try it one more time, but if it doesn’t work…
    In username.conf:

    DocumentRoot /Users/jaimeort/Sites/

    Options Indexes MultiViews
    AllowOverride All AuthConfig
    Order allow,deny
    Allow from all


  4. Oh man, tags are gone again 8( I’m really sorry, this is the las try, I’ll use html entities…
    At least it’ll be readable..

    DocumentRoot /Users/jaimeort/Sites/
    <Directory "/Users/jaimeort/Sites/">
    Options Indexes MultiViews
    AllowOverride All AuthConfig
    Order allow,deny
    Allow from all

  5. Excellent. Many thanks for this. Nice and simple and got it working perfectly first time. Thanks from New Zealand.

  6. Worked like a charm! Thanks.

    • Ken
    • February 25th, 2007

    This was a huge help, thank you!

    • romeroax
    • June 2nd, 2007

    You the man. This was the info I needed to know!

    • Matt
    • June 15th, 2007

    pretty sure i followed to the letter… still not working…. using osx 10.4.9 … anything a mac rookie might be missing here??

    used terminal to issue shell commands and text mate to edit… (many of the lines said to ‘un-comment’ were already uncommented… not sure if that’s any significance… )

    i just want mod-rewrite to work on my new mac. 🙂

  7. Matt – if you don’t have your hosts file set to make paths root relative (I plan on writing a little tutorial on that one of these days) make sure you’re using a base href tag in the <head> tag of your document…

    See this link for a little more info:

    • Matt
    • June 21st, 2007

    Thanks for the tip, got a question though… how would a base tag in the head of the destination document help me when htaccess is failing to load the document in the first place? I can type a test url in my browsers address bar:

    Where ‘test’ is not a real folder in my tree

    and in my htacces:
    Options FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^/sitefolder/$
    RewriteRule ^.*${REQUEST_URI} [R=permanent,L]

    rewriteRule ^${REQUEST_URI}&%{QUERY_STRING} [L]
    rewriteRule ^/${REQUEST_URI}&%{QUERY_STRING} [L]

    rewriteRule ^test/${REQUEST_URI}&%{QUERY_STRING} [L]

    I hope all those characters translate through the comment engine. 😉

  8. Thank you so much for this tutorial!! I was trying to get mod_rewrite to work on my local Tiger client Mac … never got it working using other tutorials.

    I’m testing it using WordPress wich had an option to enable the use of search-engine-friendly-urls’ or ‘permalinks’. Worked online but not local.

    Thanks again. Now I can start learning mod_rewrite … anyone have any good tutorials for beginners (yes i tried google)?

  9. Hi, I just found this tutorial and tried it on OS X 10.4.10.

    Here is what my username.conf file says:

    Options All
    AllowOverride All
    Order allow,deny
    Allow from all

    Mod_rewrite is still not working, though. What’s wrong? (Everything else in httpd.conf is uncommented)

  10. Whoops that code is prefaced by

    and ends with

    (That’s all that’s in the brian.conf file)

    • Heather
    • September 1st, 2007

    THANK. YOU. SO. MUCH. I wasted so much time trying to figure this out myself. Thankyouthankyouthankyou.

  11. Brian, I have the same problem. 10.4.10, all of the lines were already uncommented and as described except the line at 408 (406 in my config) which I changed accordingly.

    As for my .htaccess file, I have the directives block the same as yours. I have checked everything I can think of, scoured the Apache documentation and searched all afternoon on the net for answers. This page was the closest I came and I’m still not quite there.

    If anyone has the answer for 10.4.10 it would be gratefully appreciated. If I find it, I’ll bring it back here! Cheers

  12. Sorted it. I was getting a “RewriteRule: bad flag delimiters” error in /private/var/log/httpd/error_log – removed the comment I had put in after the rewrite rule and suddenly everything worked. Cheers for being instrumental in getting this working for me everyone.

  13. Thanks Michael !
    It was what I needed this aftrnoon when I installed a local copy of the site on OSX.
    Thanks ! It’s perfect.

    I think you should also write a brief tutorial about installing PHP, mySQL and WordPress on OSX, with your clear style.
    All the sources on the web are not clear or outdated…


  14. Thanks, Luigi!
    I’m really glad it’s helped so many people so far. It’s hysterical that you just asked about a tutorial on installing PHP and MySQL because almost two years after I’d written this I stayed up late last night and wrote just what you’re asking for (without the wordpress portion). You can read it here.

  15. You’re right !
    Pleae forgive…I’ve just found your site, and did not notice that nice tutorial.

    Perfect !


    • orko
    • December 24th, 2007

    You have no idea how hard I worked at getting this to work. I installed Drupal in three different machines and the clean URL option worked only in one of them. The other two machines refused to do it!
    I compared every file in these two machines and configured them according to Drupal instructions. Nothing. I was starting to believe that the only difference was that I had installed Apple’s Web Objects.
    The main problem is that people who write instructions write the instructions to themselves not thinking on how a non-knowledgeable person thinks (or does not think).


    By the way, PHPMYAFMIN is giving me the following alet:
    “Your PHP MySQL library version 5.0.24a differs from your MySQL server version 3.23.32. This may cause unpredictable behavior.”

    Any ideas??


    • at0g
    • April 7th, 2008

    Thanks guys, I had the same issue as Midiman… Thanks all the way from New Zealand =)

    • Senning
    • April 11th, 2008

    If you’re having trouble because your webserver keeps looking for your ./Sites/ files at /Library/WebServer/Documents/, and you don’t need to access /Library/etc…, you can add DocumentRoot “/Users/[username]/Sites/” to “yourname.conf”.
    I’m assuming that it is nicer to put it in yourname.conf so other users won’t be redirected to the same, but I’m not an expert.

    • paul
    • April 30th, 2008

    For OS X 10.4.11, Got this working with Drupal in the user/Sites dir, but needed one extra step.

    — modifying the [user].conf will allow .htaccess in the [user]/Sites/[drupal dir] to override the setting.
    — this site though is http://localhost/~%5Buser%5D/%5Bdrupal dir]
    — therefore in the .htaccess within the drupal directory needs to define where its root is through a “RewriteBase”
    — uncomment and change to “RewriteBase /~[user]/[drupal dir]”

    hope this helps a few.

    • david
    • May 19th, 2008

    I think I did everything right but when i tried to pull up my php site i got this:
    You don’t have permission to access /~david/elgreco/index.php on this server.

    any idea what i may have done wrong?


  16. I’m using Snow Leopard (OS X 10.6) and the location of my {user}.conf file is somewhere else than was described above.


    (Replace {user} with your Mac username)

  1. October 30th, 2007
  2. February 10th, 2008