Scribble

July 28, 2006

Making Mod Rewrite and htaccess work on Mac OS x

Filed under: Developer's Notes — Celia @ 7:34 am

For those of you who have got a splitting headache trying to make htaccess work on MAC OS x, Relax. I had the same problem till yesterday till I found the silly culprit.

I hope you would have done the below elementary corrections on httpd.conf, but if you still haven’t, I would suggest that you follow the below instructions.

Search for the below text in httpd.conf file, and uncomment these three lines. (You would have to remove the # in front).

#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c
#AccessFilename .htaccess

If you do not find the above lines, add it. Then, search for the text ‘AllowOverride’. Check whether it is set to None or All. If it is set to None, edit and set it to “All”.

Thats all you would have to do if you are working on a windows or a linux based server. Restart the apache server and have fun with Mod Rewrite.

Those working on Mac OS x, you would still need to do one final change.

Change to your /private/etc/httpd/users directory and you would see another conf file. If your username is ‘celia’, it would probably be named as ‘celia.conf’. If you would open the file, you would find that there is another ‘AllowOverride none’ settings there. Change it to ‘AllowOverride All’ and restart the apache webserver. Voila, you are done with the changes.

It seems that the apache that is shipped with MAC OS x does not allow htaccess by default. After doing the above changes, I was able to add mod rewrite rules. I was so overjoyed on the discovery that I thought that this deserved a post though it is a personal blog. Hope this helps someone.

If this still doesn’t help you, may be you can drop a comment here or search in forums. God Save You!!

For my neighbours: sorrry baaa.. romba manda kaanchitanaa.. adhu thaan matter solve aaana odana ore kushi aaayitu..

Advertisements

40 Comments »

  1. out of syllabus 🙂

    Comment by Syam — August 1, 2006 @ 8:50 pm | Reply

  2. women mac users are cool! did u know that? Its nice to see some woman mac user share her experiences of mac usage. Here its a self discovery. definitely warrants a comment. 🙂

    Comment by rethas — August 4, 2006 @ 3:33 am | Reply

  3. http://www.clagnut.com/blog/350/

    Comment by knownperson — August 5, 2006 @ 4:44 am | Reply

  4. @Syam – he he.. lifela oru mirchi masala venaaam?

    @rethas – Oh, c’mon da.. what is so special about ‘men mac users’ and ‘women mac users’ that we would have to differentiate them?

    @Knownperson – Oh, thanks a lot knownone. The link is good. But I would have liked it more if you could have explained a little more and given your real name here. Now, it looks more like a spam.

    Comment by Bindu — August 5, 2006 @ 3:29 pm | Reply

  5. Ok but I’m not sure whether if you really thought it was spam that you would have written a 4 line reply to it.

    Anyway take care. You are doing great ! keep it up !

    Best wishes

    Again from A knownperson (it is not knownone !)

    Comment by knownperson — August 5, 2006 @ 5:27 pm | Reply

  6. @Knownperson – 🙂 My Akismet reported it as a possible spam comment. I wanted to look into the link before doing any action and found a wonderful blog. Is that yours? Or did you found that link useful and just added it here?

    Comment by Bindu — August 6, 2006 @ 1:44 pm | Reply

  7. It is not my blog.

    Naan avvalavu peria aallu Kediathu !

    I passed the link to you as I thought it to be relevant.

    Comment by a very known person — August 7, 2006 @ 4:52 am | Reply

  8. Wow Thats really coool.. Now, Where did I see you last? Have we met?

    Comment by Bindu — August 7, 2006 @ 4:57 am | Reply

  9. Yes. We have.

    Comment by a known person — August 7, 2006 @ 10:51 am | Reply

  10. Hey this is too much.. what have I done to you that you could not even let me know your name?

    Comment by Bindu — August 7, 2006 @ 10:58 am | Reply

  11. ok take 4 guesses. Not more than that.

    Comment by knownperson — August 7, 2006 @ 1:33 pm | Reply

  12. Romba sorry.. You are not giving me any clue and you expect me to find you in 4 guesses. This is not fair. Ok, tell me something that reminds me of you 🙂

    Comment by Bindu — August 7, 2006 @ 5:16 pm | Reply

  13. Here are some points to ponder

    1. I had commented only on your technical article and not on any of your other postings.

    2. The link which I gave you was more or less very accurate to the complex technical article which you had written.

    3. I can speak tamil also.

    4. And we have met.

    Can\’t you count using your fingers, the number of persons who may fit the above four criteria ?

    Comment by knownperson — August 8, 2006 @ 4:45 am | Reply

  14. Sorry. I am tired of all this.

    Comment by Bindu — August 9, 2006 @ 5:18 pm | Reply

  15. tried about 60 minutes to get htaccess working on my macbook, read everything twice , and the googled…
    thanx for showing me the special user config file… i’would never find this by mxself. regards, and greetings from berlin nicolas

    Comment by nicolas — March 26, 2007 @ 10:24 pm | Reply

  16. Thank You! I’ve been trying to get this working for ages, I found the commented lines in the main conf file, but I don’t think I would have ever found the users conf file. One more splitting headache soothed.

    Comment by Jedidiah — May 29, 2007 @ 2:08 pm | Reply

  17. Thanks dude!!

    Comment by ptr — July 17, 2007 @ 9:17 pm | Reply

  18. Tel you what, F** these macs. I’m trying to get this htaccess to work for over a week now at my school server which is a Mac. My website is due tomorrow and it doesn’t work coz the register_globals is turned on and i need to switch it to off using htaccess. Wow. thank you steve jobs… you son of a *.

    Anyways thanks. I think i’m totally screwed.

    Comment by azz — May 4, 2008 @ 2:06 pm | Reply

  19. thanks a bunch, worked like a charme!

    Comment by chrillo.at — December 25, 2008 @ 11:47 pm | Reply

  20. […] need to mess with those files, there are a couple pretty good walkthroughs to help you out here and here. « Darth […]

    Pingback by Witheringtree » .htaccess vs. MAMP — March 7, 2010 @ 5:14 am | Reply

  21. sorry but where do I find “/private/etc/httpd/users directory” ?? New to this so I’m not sure where to look. Thank you!

    Comment by kelsey — May 4, 2010 @ 7:12 pm | Reply

  22. You saved me! No where is it mentioned in a Google search, other than here, that there are other instances of AllowOverride in a Mac apache2 installation. For me it was in private/etc/apache2/sites where you will find the separate site specific .conf files as set up by Server Admin. (I’m not using ‘User’ directories for sites) As for the post from kelsey – in Finder the Go menu gives you the option “Go to folder”. Just type /private
    Thank you.

    Comment by Gerg — May 20, 2010 @ 2:23 am | Reply

  23. On Snow Leopard the files are under /private/etc/apache2/httpd.conf
    On Snow Leopard the files are under /private/etc/apache2/users/username.conf

    To make htaccess work under /Library/WebServer/Documents/ and underlying directories you have to change the AllowOverride under too.

    Comment by reptilex — May 5, 2011 @ 12:27 pm | Reply

    • To make htaccess work under /Library/WebServer/Documents/ and underlying directories you have to change the AllowOverride under the Directory “/Library/WebServer/Documents” directive.

      (was left out because it was inside >< in my previous comment)

      Comment by reptilex — May 5, 2011 @ 12:29 pm | Reply

  24. I’ve just tried this and it doesn’t work for me. I’m using mac with 10.6.7 osx.
    I edited these files in terminal:
    /private/etc/apache2/httpd.conf
    /private/etc/apache2/users/username.conf

    and i also changed ” AllowOverride under the Directory “/Library/WebServer/Documents” directive.”

    but now when i view my site thru the websharing link in system prefs, it just says “Safari can’t connect to the server.”.

    what have I done wrong?

    Comment by Graham Cross — June 3, 2011 @ 9:29 am | Reply

  25. When i restart apache, i got a syntax error: ‘ invalid command “addModule” ‘

    Comment by kaelzhang — June 18, 2011 @ 4:43 am | Reply

  26. Thanks very much buddy, was having issues with that extra user conf file which was overriding all my good work in the main httpd.conf file!

    Btw, you shouldn’t be using “addModule”, it will cause apache to go south.

    Comment by Sam Parmenter — July 26, 2011 @ 7:40 pm | Reply

  27. Thanks, this took a lot of my time today…until I found this. You really helped me out. In osx Lion (at least) you also need to add ‘FollowSymLinks’ to the ‘Options’.

    Comment by Frank — July 30, 2011 @ 11:09 am | Reply

  28. […] on your localhost in Lion (os x 10.7+). It took about 2 hours of digging but I finally found a great post which outlines the process of setting up Lion’s native apache2 install to accept .htacces […]

    Pingback by Configure Wordpress on Lion osx 10.7 » Designing My Future — September 22, 2011 @ 11:40 pm | Reply

  29. Damn! That user specific file. I wasted 2 days with it until I discovered your post. On lion it’s at /private/etc/apache2/users/.conf.

    Comment by Ashish Gandhi — November 4, 2011 @ 4:23 am | Reply

  30. Thanks for the post. Mystery solved!!!

    Comment by prarie — February 12, 2012 @ 8:09 pm | Reply

  31. me salvaste la vida!! pero en mac shot leporad era así:

    /private/etc/apache2/httpd.conf
    acá cambias:
    AllowOverride None > AllowOverride All
    en la consola:
    apachectl -M | grep rewrite
    FIN!

    Comment by Nicolas Torres — May 18, 2012 @ 5:59 pm | Reply

  32. On Mountain Lion, just using the “AllowOverride: All” command worked. The previous bits caused failure. Cheers!

    Comment by Anon — December 30, 2012 @ 4:54 pm | Reply

  33. […] on your localhost in Lion (os x 10.7+). It took about 2 hours of digging but I finally found a great post which outlines the process of setting up Lion’s native apache2 install to accept .htacces […]

    Pingback by Configure Wordpress on Lion osx 10.7 | Mike Freeman Design — January 25, 2013 @ 1:21 am | Reply

  34. […] on my localhost in Lion (os x 10.7+). It took about 2 hours of digging but I finally found a great post which outlines the process of setting up Lion’s native apache2 install to accept .htacces […]

    Pingback by Configure Wordpress on Lion osx 10.7Mike Freeman Design — January 27, 2013 @ 3:30 am | Reply

  35. Nice work — and THANK YOU!! I just migrated to a Mac server and ran into this problem after changing my permalinks…but it wasn’t even until an hour later that I realized that my pages were returning 404 errors. I was running on 3 hours of sleep and didn’t even think of the .htaccess settings. Great find and thanks again for sharing!

    Comment by Nina Fae — December 23, 2013 @ 10:36 pm | Reply

  36. Chance would be a fine thing…

    Thought I’d found the answer to this niggling problem in this post but when I uncommented the final two lines (see below) my install of MAMP 2.1.3 wouldn’t run. Apache wouldn’t load. Plus I can’t find my /private/etc/httpd/users users directory anywhere!!!

    I’d already tried upgrading to MAMP 3 where ModRewrite DOES work — unfortunately none of my sites do. It seems that the version of Apache is too far ahead of the SilverStripe CMS that I’m using.

    Any tips out there? It would be great to have this resolved — at the present time I just have to trust that any issues I encounter where ModRewrite needs to be working will (hopefully) be resolved when I upload site to life server which DOES do ModRewrite!!!

    I’ve spent days on this so please excuse my frustration!!

    Comment by Mike Henden — August 13, 2014 @ 5:00 am | Reply

  37. Ack! Forgot to post the lines in question:

    LoadModule rewrite_module modules/mod_rewrite.so
    #AddModule mod_rewrite.c
    #AccessFilename .htaccess

    If I uncomment the last two lines Apache won’t load. At all.

    Comment by Mike Henden — August 13, 2014 @ 5:09 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: