AEM: debugging Apache rewrite rules on dispatcher

Jeroen Druwé
WeAreIDA
Published in
2 min readFeb 8, 2021

On my current project, we have many Apache rewrites rules configured. I recently discovered an issue in one of our rules that caused our product pages not to render correctly. It can be quite cumbersome to check every single rule, I went looking for a better solution and found one: mod_rewrite logging using the LogLevel directive.

Within your <VirtualHost> directive

LogLevel alert rewrite:trace3

mod_rewrite offers detailed logging of its actions at the trace1 to trace8 log levels. The log level can be set specifically for mod_rewrite using the LogLevel directive: Up to level debug, no actions are logged, while trace8 means that practically all actions are logged. Using a high trace log level for mod_rewrite will slow down your Apache HTTP Server dramatically! Use a log level higher than trace2 only for debugging!

- http://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging

tail -f error_log | fgrep '[rewrite:'

Can for example result in the following:

[rewrite:trace3] mod_rewrite.c(470): applying pattern '^/nl-be/products/([0-9]+)(/.+)?' to uri '/nl-be/products/1234.html'
[rewrite:trace2] mod_rewrite.c(470): rewrite '/nl-be/products/1234.html' -> '/content/company/be/nl.pdp.1234'

If you have any questions about this topic, do not hesitate to contact us or leave a comment below.

https://www.ida-mediafoundry.be/

--

--