Friday, April 20, 2018

mod rewrite - How to debug Apache mod_rewrite



I have two main problems with mod_rewrite:



1) There is no meaningful error reported when I have an invalid rule




enter image description here



2) To reliably test each modification, I have to erase chrome's cache. This isn't rocket science, but I have to hit Ctrl+Shift+Delete then click OK, then close the window, and reload.



I'd like to see if any of the gurus are willing to share their secrets to efficiently managing mod_rewrite code.


Answer



One trick is to turn on the rewrite log. To turn it on,try these lines in your apache main config or current virtual host file (not in .htaccess):



RewriteEngine On

RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 3


Since Apache httpd 2.4 mod_rewrite RewriteLog and RewriteLogLevel directives has been completely replaced by the new per-module logging configuration.



LogLevel alert rewrite:trace6

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...