mod_rewrite

How to Enabled mod_rewrite Debug Log in cPanel

If you are using mod_rewrite & find out some problem, you may need to do some debugging with the log write somewhere. For CentOS system with cPanel together with Apache or LiteSpeed, you may enabled mod_rewrite Debug Log as below.

  • Edit Apache configuration located in “/etc/httpd/conf/httpd.conf
  • Find the corresponding VirtualHost for your domain which you want to debug.
  • Add “RewriteLogLevel 9” underneath “UseCanonicalName” as below and save.
<VirtualHost 100.100.100.100:80>
  ...
  ...
  UseCanonicalName Off
  RewriteLogLevel 9
  ...
  ...
</VirtualHost>
  • Restart Apache or LiteSpeed
  • The Debug Log will be written in “/usr/local/apache/logs/error_log” file.

How to Check mod_rewrite Module in Apache/LiteSpeed is Loaded

To check if mod_rewrite Module is loaded in Apache/LiteSpeed follow the following steps

1. For system with cPanel, log to SSH in issue the following commands

/usr/local/apache/bin/httpd -D DUMP_MODULES | grep rewrite

If it return the following, then mod_rewrite is loaded

Syntax OK
rewrite_module (static)

2. For system with no cPanel, check “httpd.conf” file. If the following is in the file then it should be loaded.

LoadModule rewrite_module libexec/apache2/mod_rewrite.so