8

How do you troubleshoot Apache redirects in production? I know there's a logging feature somewhere that lets you log all the redirects that happen...

3 Answers 3

8

To log what's going on in the mod_rewrite module you need to set RewriteLog and RewriteLogLevel:

RewriteLog         /path/to/mod_rewrite.log
RewriteLogLevel    2

in your Apache config (you can't set them in your .htaccess).

Note that logging has changed in Apache 2.4.

2
  • 1
    This will not work if they are actual Redirects and not RewriteRules.
    – Vinko Vrsalovic
    May 22, 2009 at 18:00
  • Very true, I was making the assumption that he was using mod_rewrite :)
    – Nathan
    May 22, 2009 at 20:09
2

To get additional debugging information for debugging Apache issues (such as redirects), you can add RewriteLog and RewriteLogLevel to the configuration. The specifics of the configurations are different between Apache 2.2 and 2.4, so please check the version of Apache you are running.

Please check the logs, as they may tell you the specific details of what is causing the redirect. In general, Apache redirects can be troubleshot by adding the following to the Apache 2.4 configuration:

LogLevel alert rewrite:trace6

reference: http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging

I see that you have replaced the specifics of the Apache configuration for security. This is good, but I can't check the SSL for the domain due to this. There could also be an issue with Server Name Indication (SNI) which the browser is using for that domain name which does not match the Apache configuration.

It may be possible that DirectAdmin has added a configuration in addition to another configuration. Please check that you do not have multiple sections with the same IP address and port.

You may also want to confirm the domain matches the website's configuration. Depending on what CMS you are running (Magento, WordPress, Joomla!, etc.), it could be redirecting back to the original domain which Apache redirected from.

2
  • Hello and welcome to ServerFault. Don't you think your answer could be trimmed down a bit?
    – kubanczyk
    May 8, 2018 at 15:20
  • I'm not sure what details I should leave out. If you tell me what to trim, I will be happy to erase the information from the response. Jun 19, 2018 at 12:28
0

I generally create my own verbose CustomLog. In it, I include the HTTP Response header Location

I also include other things such as the response time and HTTP Request header X-Forwarded-For, amongst a select other few things.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .