I cannot get mod_rewrite to work on Lion. I am developing a number of websites locally, in ~/Sites, using .htaccess files. I am on 10.7.3 and I have not touched any configuration files except for enabling PHP in httpd.conf (which works).

I know there are at least 2 questions about this here, but the solutions detailed there don't work. Nor do the other solutions that I have found on the web. I must be doing something stupid or overlooking something, or else I am probably going crazy, but it's not working.

I've tried all the usual stuff:

  1. In /private/etc/apache2/users/<myusername>.conf, change AllowOverride None to AllowOverride All and restart the web server

  2. Additionally, in /private/etc/apache2/httpd.conf, change any/all occurrence(s) of AllowOverride None to AllowOverride All -- I've tried it in all the various places where these directives are found

  3. Try basically all possible combinations of values for the Options line above/below the AllowOverride line, including the values: Indexes MultiViews FollowSymLinks All

Always restarting the web server after such a change, of course. None of this works. All my clean urls simply do not work; I get a 404 - not found. Apache's error log just gives me "File does not exist:" errors. So it seems that the mod_rewrite module is not even working at all.

I made sure that mod_rewrite is loaded in the httpd.conf, which it is; it is so by default on a Lion install.

The crazy thing is that everything had been working perfectly -- until I migrated to a new machine running Lion. That is, I am ruling out an error in my .htaccess files because I know it worked before. Also, if it was an error in the .htaccess, I would get some kind of error message from the mod_rewrite module in Apache's error_log, at least telling me that the module itself is being called. But this is not happening.

Am I overlooking something? Do I have to change config settings someplace else? Do I have to change PHP's config? Why are the instructions (like How to activate mod_rewrite on MacOSX Lion and getting mod_rewrite to work on Mac OS X) working for other people but not for me? :)

I've wasted hours on this already. Any help would be VERY appreciated.

  • BTW, I don't want to use MAMP. I used MAMP before and it didn't play well with the MySQL that is already on my system. This would be replacing one headache with another headache, so no thanks :) Commented Apr 3, 2012 at 20:11
  • BTW I am on standard OS X Lion, NOT Lion Server. Commented Apr 3, 2012 at 20:12
  • This doesn't answer the question, but an alternative to wrestling with your Mac's local environment for doing web dev is to use something like Vagrant, which lets you easily set up and manage virtual-machine configurations.
    – Dan J
    Commented Aug 20, 2013 at 17:10

6 Answers 6


You should make sure that in your /etc/apache2/users/username.conf you have the following:

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

The FollowSymlinks and AllowOverride are essential here. While you are hinting at both in your question, maybe you did not configure these correctly in tandem.

Make sure in httpd.conf /private/etc/apache2/extra/httpd-userdir.conf is included as well. It is by default.

After any modifications, restart the web server for the changes to take effect.

If you are still having problems, maybe there is a problem with your actual rewrite rules. Were you using them in a .htaccess context before as well? Note that in a .htaccess, the rewrite rule regex is matched against a request URI without the leading slash and always relative to the directory where the .htaccess resides, whereas in a global httpd.conf the URI must match with a leading slash and is relative to the web root. Because assumedly you have your .htaccess in a subdirectory of ~/Sites, your rewrite rules might behave different from when the .htaccess resides in the web root of a (virtual) host.

To debug mod_rewrite you can enable rewrite logging. You should enable that in /etc/apache2/httpd.conf:

RewriteLogLevel 3
RewriteLog /path/to/rewrite.log
  • Thanks Gerry. Yes, I tried that; just tried it again; does not work unfortunately. I have not changed the .htaccess, it is in ~/Sites/…, as it was before. This is too frustrating :( Commented Apr 4, 2012 at 19:24
  • Try enabling rewrite logging like I amended above.
    – Gerry
    Commented Apr 4, 2012 at 19:50
  • OK, it's not a problem with mod_rewrite at all, as it seems; it's the .htaccess file that is completely ignored. I can place any junk into it and I get no error message. So Apache is not loading it. I checked permissions, they are ok (the file is world-readable). I tried making it executable, no change. Commented Apr 4, 2012 at 20:29
  • If I place a .htaccess into /Library/WebServer/Documents and open "localhost" to test it, this works as expected. It just doesn't work in "~/Sites". Commented Apr 4, 2012 at 20:30
  • I did something crazy and created a second user account with the login name "testitester". I set AllowOverride to All in that user's .conf. I placed a .htaccess containing junk in that user's Sites folder. If I go to localhost/~testitester, I get a 500 error, as expected. Commented Apr 4, 2012 at 21:19

Adding Options +FollowSymLinks worked fine for me

Options +FollowSymLinks

RewriteEngine on
RewriteBase /
  • what it is doing with Options +FollowSymLinks ? I just add that line it works for me
    – Kannika
    Commented Sep 5, 2016 at 16:15

I was experiencing a similar problem where my .htaccess file was being completely ignored while in a subfolder inside my ~/Sites directory under a VirtualHost that was setup correctly.

Having spent the last hour playing around with different configuration files and setting AllowOverride All in various places, I finally found out that the .htaccess file, while it looked like a .htaccess file in Finder, was actually a .htaccess.txt file with the extension hidden.

To check and change your .htaccess file, right click on it and choose Get Info and then make sure to remove any leading extension from the end, such as the one I had:

And now it works!


Below .htaccess entries fix for me

Options Indexes FollowSymLinks

<ifModule mod_rewrite.c>

RewriteEngine On
#RewriteBase /~charles/Sites/Timesheet/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]


Placing .htaccess into /Library/WebServer/Documents and open "localhost/"; to test it, works as expected. It just doesn't work in "~/Sites". Thanks Niels Heidenreich for this!


When you type: /Users/username/app_name

The / refers to the root of the webserver:


If you use /~username/app_name in your rewrite it should work.

  • 1
    Paths starting with / are always absolute paths for Apache, see definition of webserver root in http.conf (<Directory "/Library/WebServer/Documents">)
    – nohillside
    Commented Jan 31, 2013 at 7:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .