Request exceeded the limit of 10 internal redirects due to probable configuration error
Asked Answered
A

7

64

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:

http://book.cakephp.org/2.0/en/getting-started.html

Aquilar answered 6/4, 2013 at 12:17 Comment(0)
A
108

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>
Aquilar answered 6/4, 2013 at 12:26 Comment(7)
for cake 2.4.1, the .htaccess is the one in the folder which contains app, lib, plugins, vendor; not the app/webroot. also the one important change is to add the RewriteBase /... the other parts of the .htaccess may not match and that is fine.Doff
Great solution yaar... I happens in my codeigniter, centos 6 environment, thanks.Been
How would you fix this for WindowsPremolar
I can confirm as of 1/23/2016 that this works. Thanks. My .htaccess was previously: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule>Bunkum
I just had to un-comment this line 'RewriteBase /' in my .htaccess , thx u!!Cattycornered
Thanks! It worked for me, you saved me a lot of time!Gaiety
Worked like a charm for me Windows 10 / Wampp / Yii2 I set up it as advanced local websiteFascicule
W
11
//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]
Wiretap answered 22/3, 2018 at 14:11 Comment(0)
S
2

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.

Spitler answered 13/5, 2016 at 4:5 Comment(0)
S
2

i solved this by http://willcodeforcoffee.com/2007/01/31/cakephp-error-500-too-many-redirects/ 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

Safekeeping answered 22/8, 2019 at 10:28 Comment(2)
Dead link. No coffee?Kermitkermy
i'm going to take someSafekeeping
B
1

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>
Boost answered 11/7, 2021 at 8:58 Comment(0)
M
0

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

Mettah answered 5/10, 2021 at 2:1 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Payer
R
0

In our codeigniter with apache environment, we need to add .htaccess at to root level of application. Below is the .htaccess content;

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Rozanneroze answered 23/1, 2023 at 3:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.