mod_rewrite Not Working in .htaccess - Solution
By Angsuman Chakraborty, Gaea News NetworkMonday, July 10, 2006
I faced a hair-tearing problem. mod_rewrite was loaded and yet it was not working in .htaccess files (and httpd.conf initially). Here is the solution along with how you can debug mod_rewrite problems.
Debugging procedure:
Add these two line to your httpd.conf immediately after RewriteEngine On.
RewriteLog “/var/log/httpd/rewrite_log”
RewriteLogLevel 9
After that I added the required RewriteRule etc.
The reason for testing directly in httpd.conf is to ensure that mod_rewrite is working in the first place. After some debugging I realized my expression was wrong. So now I found mod_rewrite was working in httpd.conf. However it still wasn’t working in .htaccess files.
Solution:
I found AllowOverride was set to None in httpd.conf. I changed it to All (after all I am the only user of the machine). And it finally started working everywhere (after a restart).
What I learnt:
Unmanaged dedicated web hosting is really really painful, unless you are (or have) a good linux system administrator. Too many things to setup and too many points of failure. And I haven’t even started working on serious hardening stuff.
| 
                         January 4, 2010: 6:38 pm  Thank you… thank you… thank you. I was just about to quit web development and take religious vows. RewriteLogLevel 9 - Awesome | 
| 
                         December 2, 2009: 5:07 pm  was going insane and your quick tip of “I found AllowOverride was set to None in httpd.conf” was the key! years on your still helping folk! thanks | 
|   Sajith | 
|   Paul | 
|   MJ | 
|   Travis | 
                         July 16, 2009: 1:52 am  Thanks a lot for this. Helped me get mod_rewrite going on a new OS X Leopard install, with a slightly different log path: “/var/log/apache2/rewrite_log”. | 
|   Jeff | 
|   omg | 
|   Luca | 
|   rajv | 
|   Jcart | 
|   Saurabh | 
| 
                         December 20, 2007: 9:55 pm  Man, when you said hair pulling, you weren’t kidding. I probably spent 4-5 hours trying to resolve the same issue. This game is not for people with short attention spans. | 
| 
                         October 19, 2007: 12:50 pm  Thank you so much, I’ve been trying everything and the AllowOverride has worked. | 
| 
                         March 10, 2007: 3:01 pm  THANKS A LOT!!! Your so small, but so clever tip saved my permalinks from death  | 
|   SacrificE | 
|   Matt | 
                         July 15, 2006: 6:52 pm  Thanks! I was racking my brain trying to figure it out…AllowOverride was set to None in httpd.conf | 
 
                         
                         
                         
                         
                         banging my head on it for hours, thanks to you and google
 banging my head on it for hours, thanks to you and google 
                         
                         
                        
JohnM