How to set up MAMP to enable .htaccess and mod_rewrite debugging
Here is how to enable htaccess overrides in a MAMP server for local development. This is useful to test PHP configurations where you want to use a .htaccess
file to redirect all requests to a specific file, say, an index.php
that acts as a router, enabling you to use pretty URIs such as /users
, /users/new
, etc. for your PHP application.
Enable .htaccess overrides in the entire server
Before:
1
2
3
4
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
After:
1
2
3
4
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Enable mod_rewrite log for debugging
1
2
3
4
5
# Mod rewrite configs
RewriteEngine On
RewriteLog "/Applications/MAMP/logs/rewrite.log"
RewriteLogLevel 5
Then you can tail -f /Applications/MAMP/logs/rewrite.log
to debug your rewrites.
Danger:
These configurations are a serious security hole and therefore are for development ONLY!