Enable URL rewriting (mod_rewrite) using .htaccess files in ~/Sites on Lion 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:


In /private/etc/apache2/users/&lt;myusername&gt;.conf, change AllowOverride None to AllowOverride All and restart the web server
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
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.
You should make sure that in your /etc/apache2/users/username.conf you have the following:

&lt;Directory "/Users/username/Sites/"&gt;
    Options Indexes MultiViews FollowSymlinks
    AllowOverride All
    Order allow,deny
    Allow from all
&lt;/Directory&gt;


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