Detect Infinite Loops


So, I just rebuilt a site that had about 500 redirects. I did some crunching and was able to reduce that down to about 300 with some fancy rewrites.

Of course, fancy rewrites also increases the odds of infinite redirects.

Is there a way to get Apache to log whenever someone gets an infinite redirect, so we can watch for them and fix them?


I haven’t tested this myself, but from what I read elsewhere (e.g. here) is that Apache already puts that in its error log. All you’d need to do is create a scripts that fetches that exact error out of it (look for “MaxRedirects”) or use the *nix command line if you have access to that. Something like:

cat /path/to/my/error.log | grep MaxRedirects