I have a RewriteRule in a .htaccess file that isn’t doing anything. How do I troubleshoot this?
- How can I verify if the
.htaccessfile is even being read and obeyed by Apache? Can I write an echo “it is working” message, if I do write it, where would that line be echoed out? - If the
.htaccessfile isn’t being used, how can I make Apache use it? - If the
.htaccessis being used but myRewriteRulestill isn’t having an effect, what more can I do to debug?
Enter some junk value into your
.htaccesse.g.
foo bar,sakjnaskljdnasany keyword not recognized by htaccess
and visit your URL. If it is working, you should get a
I suggest you to put it soon after
RewriteEngine on.Since you are on your machine. I presume you have access to apache
.conffile.open the
.conffile, and look for a line similar to:If it is commented(#), uncomment and restart apache.
To log rewrite
Put the above 3 lines in your
virtualhost. restart the httpd.RewriteLogLevel 9Using a high value for Level will slow down your Apache server dramatically! Use the rewriting logfile at a Level greater than 2 only for debugging!Level 9 will log almost every rewritelog detail.
UPDATE
Things have changed in Apache 2.4:
FROM Upgrading to 2.4 from 2.2
For more on LogLevel, refer LogLevel Directive
you can accomplish
in this manner now