mod_rewrite Not Working in .htaccess - Solution
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.
Filed under Headline News, How To, Linux, Open Source Software, Pro Blogging, Tech Note, Web, Web Hosting, Web Services |
|
RSS 2.0 |
Trackback this Article
|
Email this Article
You may also like to read |




































July 15th, 2006 at 6:52 pm
Thanks! I was racking my brain trying to figure it out…AllowOverride was set to None in httpd.conf
August 15th, 2006 at 7:23 am
Thanks DOOD ! =)))) it worked for me !
thx a lot!
March 10th, 2007 at 3:01 pm
THANKS A LOT!!! Your so small, but so clever tip saved my permalinks from death
October 19th, 2007 at 12:50 pm
Thank you so much, I’ve been trying everything and the AllowOverride has worked.
December 20th, 2007 at 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.
December 22nd, 2007 at 11:01 pm
I dont get any error in rewrite_log nor rewite is working.
December 23rd, 2007 at 11:40 am
Thanks Angsuman! It worked wonders
March 23rd, 2008 at 2:29 pm
Thanks a lot, this fixed my problem as well.
April 18th, 2008 at 10:28 am
this one was it
banging my head on it for hours, thanks to you and google
June 6th, 2008 at 1:44 am
Thanks. You save my life!