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
- The Cake Folder .htaccess
- The App Folder .htaccess
- 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 (testing.blah.com)
- 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. testing.blah.com/user/login) 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: http://irc.cakephp.org/cakephp/viewlog/2007-01-11#2234 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.