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>
  • By: Andrew Kirkpatrick
  • In: Uncategorised
  • Under: