Enabling Rewrite Logs¶
The first step to debugging rewrite rules is to enable rewrite logging. Once rewrite logging has been enabled, you will be able to check the log to see which rewrite rule is not working and what is going wrong.
You can enable rewrite logging in your Apache configuration.
Locate the virtual host where the error is occurring.
Note
Make sure you find the correct virtual host (i.e. 80, 443, or both if required). You won't see any rewrite log output if you set it to the wrong virtual host.
Open the relevent config file and add the RewriteLogLevel
directive followed by a number for how detailed you want your logs to be. 1
is least detailed. 9
is most detailed. 0
will turn off rewrite logging. For example:
<IfModule LiteSpeed>
RewriteLogLevel 9
</IfModule>
Graceful restart LiteSpeed Web Server so the changes will take effect.
Important
The Apache 2.4 rewrite log directive LogLevel alert rewrite:trace3
is not yet supported by LiteSpeed. You must use RewriteLogLevel
to enable rewrite logging for LiteSpeed, even if you run Apache 2.4.
More information on Apache rewrite log configuration can be found in the Apache mod_rewrite documentation.