Request exceeded the limit of 10 internal redirects due to probable configuration error
ApacheCakephpApache Problem Overview
I'm getting the following error in my CakePHP application:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://projectname.dev/
My .htaccess in the root folder, looks like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
and in the app folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
and in the webroot folder:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectname
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
I was following this tutorial:
Apache Solutions
Solution 1 - Apache
I just found a solution to the problem here:
https://willcodeforcoffee.com/cakephp/2007/01/31/cakephp-error-500-too-many-redirects.html
The .htaccess file in webroot should look like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
instead of this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectname
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Solution 2 - Apache
//Just add
RewriteBase /
//after
RewriteEngine On
//and you are done....
//so it should be
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Solution 3 - Apache
i solved this by
http://willcodeforcoffee.com/2007/01/31/cakephp-error-500-too-many-redirects/</strike>
just uncomment or add this:
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
to your .htaccess file
Solution 4 - Apache
This error occurred to me when I was debugging the PHP header() function:
header('Location: /aaa/bbb/ccc'); // error
If I use a relative path it works:
header('Location: aaa/bbb/ccc'); // success, but not what I wanted
However when I use an absolute path like /aaa/bbb/ccc
, it gives the exact error:
> Request exceeded the limit of 10 internal redirects due to probable > configuration error. Use 'LimitInternalRecursion' to increase the > limit if necessary. Use 'LogLevel debug' to get a backtrace.
It appears the header function redirects internally without going HTTP at all which is weird. After some tests and trials, I found the solution of adding exit after header():
header('Location: /aaa/bbb/ccc');
exit;
And it works properly.
Solution 5 - Apache
Following the cakePHP official documentation, the .htaccess should be like this:
https://book.cakephp.org/2/en/installation/url-rewriting.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
Solution 6 - Apache
simply removing the rewrite base in the internal .htaccess file fixed mine . like a had an htaccess file in my root directory simply linking to an index page in the public directory which is in my root folder then i had another htaccess file rewriting each request to the index page in that same public folder , and removing the RewriteBase fixe mine . as shown below
this is the first .htaccess file in the root directory