Apache VirtualHost .htaccess issue, Request exceeded the limit of 10 internal redirects, redirected from r->uri…

For some reason (not sure of the exact cause) but .htaccess can cause an internal Apache redirect loop which loops back onto itself before it hits your PHP (or whatever) script

In my case it was an issue with VirtualDocumentRoot (not sure if there were too many or what exactly)

If you see error_log messages like this…

[Wed Jun 13 10:34:35 2012] [error] [client 127.0.0.1]
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://virtualhost/

And debug error_log messages like this…

[Wed Jun 13 10:35:44 2012] [debug] core.c(3118):
[client 127.0.0.1] redirected from r->uri =
/virtualhost/public/index.php, referer: http://virtualhost/

One way that may work to fix this (works on my Mac and a CentOS server) that I found on Stack OverflowΒ is to update the htaccess file in the public directory

RewriteRule ^(.+)$ /index.php/$1 [NC,L,QSA]

Another possible solution (not sure if it’s the best solution, please comment if you know a better one!) is to add an explicit VirtualHost with a set DocumentRoot

<VirtualHost cva:80>
    DocumentRoot "/usr/local/zend/apache2/htdocs/cva/public"
</VirtualHost>

13 comments

Leave a Reply to David Friel Cancel reply

  • Thanks from the heart!
    I started getting this error after a system update and had to spend 24h awake…
    The solution was your first option.

    πŸ˜€

  • Yes thank you Andrew. Solution 1 worked for me as well. Been approaching 24 hrs here as well, although I did manage to get 5 hours sleep :-0 You da man!

  • Hi,

    I’m having the issue, I’m in the htaccess file for the site but a little lost on the above.

    When giving this solution do you mean I replace certain code in the file, add in or I’m looking for something specifically to change?

    RewriteRule ^(.+)$ /index.php/$1 [NC,L,QSA]

    Thanks,

    David

    • # BEGIN WordPress

      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      # END WordPress
      low,deny
      Deny from all

      • Hi David,

        Normally you should just need to update the index.php rewrite rule, as in:

        #RewriteRule ^.*$ index.php [NC,L]
        RewriteRule ^(.+)$ /index.php/$1 [NC,L,QSA]

        But since WordPress has 2, I’m not sure how the replacement rule I mentioned would work (as the above is a fix for Zend Framework, and I’ve never had the issue with WordPress I’m afraid)

  • In case future folks stumble across this…

    I had a similar problem, where my Laravel 5.1 project was giving 500 errors on the browser and `Request exceeded the limit of 10 internal redirects due to probable configuration error` in the logfile.

    I was able to solve it by adding `RewriteBase /` just after `RewriteEngine On` in my `.htaccess` file.

    Hopefully this can help someone.