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

前端 未结 4 969
再見小時候
再見小時候 2020-12-05 00:01

I\'m getting the following error in my CakePHP application:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use \'LimitInter

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 00:06

    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.

提交回复
热议问题