CakePHP: Error 500 Too Many Redirects

Another error I ran into was this error:

Request exceeded the limit of 20 internal redirects due to probable configuration error. Use 'Limit InternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

It took a lot of looking, and I found out that it was an error in my .htaccess file. However, there are three major .htaccess files in a typical CakePHP application

  1. The Cake Folder .htaccess
  2. The App Folder .htaccess
  3. The Webroot Folder .htaccess

It’s hard to figure out which .htaccess file you have to edit, but my first guess was the webroot folder.

I have setup my directory structure using the alternative setup described later in the CakePHP manual:

  • webroot: This is in /var/www/testing (where testing is the virtual directory of my application (
  • app: This is in /home/eric/cake/testingapp
  • cake: This is in /home/eric/cake/cake_1.1.12.4205

The setup seemed to be working, and my normal front page appeared, but if I went to another controller (i.e. I would get the Error 500 message and the Apache error log file said I had done too many redirects in the application.

The solution is extremely easy, but it was very hard to find! But I found it on the IRC logs here: courtesy of poLK:

Edit the .htaccess file in webroot (for me that was in /var/html/testing/.htaccess) and add the line “RewriteBase /” to the file, so my .htaccess file now looks like this:

RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

It's a simple change, but took me about an hour or two of research, Google and Groups searching to figure out.

16 Replies to “CakePHP: Error 500 Too Many Redirects”

  1. It took me 3 hours to end up looking on google and finding this post.

    Thanks a mill !!!
    I think it should be something written on the Cake manual

  2. Altought rewritebase wasn’t my problem, I got to this error just because app and app/webroot htaccess were missing due to compressing program not adding them – thanks, helped me fix that.

  3. Thanks for the tip Tomas. You do have to watch out for losing the .htaccess files, especially when you’re on a Unix/Linux system since they’re hidden. 😛

  4. THANK YOU!!!

    It didn’t save me a few hours, but it really helped me from throwing my computer out the window!

    They should have written this in the cake manual where it gives instructions for the advanced install.

  5. Hi guys, I am having this error since Monday. I am looking for the solution. This one looks that could help but so far it didnt. I put this piece of code to all of the htaccess but it is still not went through. Do you have any other ideas how to fix this? Thanks

  6. Hi Joe,
    I would start checking other rewrite rules in your .htaccess files, you might have something else affecting it.

Leave a Reply

Your email address will not be published. Required fields are marked *