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

I get the following error in an elgg installation on a centos server with cPanel.

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.

The error occurs because of below rule:

RewriteRule ^([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2 [QSA,L]  

I installed elgg on a similar server without cpanel and I had no problem.

Here is my http.conf file:

Include "/usr/local/apache/conf/includes/pre_main_global.conf"
Include "/usr/local/apache/conf/includes/pre_main_2.conf"


LoadModule bwlimited_module modules/mod_bwlimited.so


Include "/usr/local/apache/conf/php.conf"
Include "/usr/local/apache/conf/includes/errordocument.conf"

ErrorLog "logs/error_log"
DefaultType text/plain
ScriptAliasMatch ^/?controlpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?kpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?securecontrolpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securecpanel/?$ /usr/local/cpanel/cgi-sys/sredirect.cgi
ScriptAliasMatch ^/?securewhm/?$ /usr/local/cpanel/cgi-sys/swhmredirect.cgi
ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi

Alias /bandwidth /usr/local/bandmin/htdocs/
Alias /img-sys /usr/local/cpanel/img-sys/
Alias /java-sys /usr/local/cpanel/java-sys/
Alias /mailman/archives /usr/local/cpanel/3rdparty/mailman/archives/public/
Alias /pipermail /usr/local/cpanel/3rdparty/mailman/archives/public/
Alias /sys_cpanel /usr/local/cpanel/sys_cpanel/

ScriptAlias /cgi-sys /usr/local/cpanel/cgi-sys/
ScriptAlias /mailman /usr/local/cpanel/3rdparty/mailman/cgi-bin/
ScriptAlias /scgi-bin /usr/local/cpanel/cgi-sys/scgiwrap

<Directory "/">
    Options All
    AllowOverride All
</Directory>

<Directory "/usr/local/apache/htdocs">
    Options Includes Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all    
</Directory>

<Files ~ "^error_log$">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    CustomLog "logs/access_log" common

    <IfModule logio_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    </IfModule>

</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"

</IfModule>

<Directory "/usr/local/apache/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_log_config.c>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent

    CustomLog logs/access_log common

</IfModule>

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

</IfModule>
PidFile logs/httpd.pid
LockFile logs/accept.lock
Listen 0.0.0.0:80
Listen [::]:80
User nobody
Group nobody
ExtendedStatus On
ServerAdmin user@gmail.com
ServerName wdsl.saptik.com
LogLevel debug

# These can be set in WHM under 'Apache Global Configuration'
Timeout 300

ServerSignature On

<IfModule prefork.c>

</IfModule>
<IfModule itk.c>

</IfModule>

RewriteEngine on
RewriteMap LeechProtect prg:/usr/local/cpanel/bin/leechprotect
RewriteLock /usr/local/apache/logs/rewrite_lock

# Set UserDir directory for all virtual hosts, except..
UserDir public_html
# when the following two modules are loaded
<IfModule mod_ruid2.c>
UserDir disabled
</IfModule>
<IfModule itk.c>
UserDir disabled
</IfModule>

# DirectoryIndex is set via the WHM -> Service Configuration -> Apache Setup -> DirectoryIndex Priority
DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html

# SSLCipherSuite can be set in WHM under 'Apache Global Configuration'

SSLPassPhraseDialog  builtin
SSLSessionCache         dbm:/usr/local/apache/logs/ssl_scache
SSLSessionCacheTimeout  300
SSLMutex  file:/usr/local/apache/logs/ssl_mutex
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin

    Listen 0.0.0.0:443
    Listen [::]:443
    AddType application/x-x509-ca-cert .crt
    AddType application/x-pkcs7-crl .crl


AddHandler cgi-script .cgi .pl .plx .ppl .perl
AddHandler server-parsed .shtml
AddType text/html .shtml
AddType application/x-tar .tgz
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlc .wmlc
AddType application/vnd.wap.wmlscriptc .wmlsc

<Location /whm-server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 ::1
</Location>



# SUEXEC is supported

Include "/usr/local/apache/conf/includes/pre_virtualhost_global.conf"
Include "/usr/local/apache/conf/includes/pre_virtualhost_2.conf"

# DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
NameVirtualHost 0.0.0.0:80
NameVirtualHost 127.0.0.1:80
NameVirtualHost *
# DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.

<VirtualHost 0.0.0.0:80>
    ServerName 0.0.0.0
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin user@gmail.com
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
</VirtualHost>


# Default vhost for unbound IPs

<VirtualHost *>
    ServerName wdsl.adomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin user@gmail.com
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
</VirtualHost>

# DO NOT EDIT. AUTOMATICALLY GENERATED.  IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.


# SSL





# CPANEL/WHM/WEBMAIL/WEBDISK PROXY SUBDOMAINS

<VirtualHost 0.0.0.0:80 127.0.0.1:80>
    ServerName wdsl.adomain.com

    ServerAlias cpanel.* whm.* webmail.* webdisk.*

    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin user@gmail.com
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^cpanel\.
    RewriteRule ^/(.*) http://127.0.0.1:2082/$1 [P]

    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^webmail\.
    RewriteRule ^/(.*) http://127.0.0.1:2095/$1 [P]

    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^whm\.
    RewriteRule ^/(.*) http://127.0.0.1:2086/$1 [P]

    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^webdisk\.
    RewriteRule ^/(.*) http://127.0.0.1:2077/$1 [P]

    UseCanonicalName Off
</VirtualHost>






# CPANEL/WHM/WEBMAIL/WEBDISK PROXY SUBDOMAINS

<VirtualHost 0.0.0.0:443 127.0.0.1:443>
    ServerName wdsl.adomain.com

    ServerAlias cpanel.* whm.* webmail.* webdisk.*

    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin user@gmail.com
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
    RewriteEngine On
    <IfModule mod_ssl.c>
        SSLEngine on
        SSLProxyEngine On
            SSLCertificateFile /var/cpanel/ssl/cpanel/cpanel.pem
        SSLCertificateKeyFile /var/cpanel/ssl/cpanel/cpanel.pem
        SSLCertificateChainFile /var/cpanel/ssl/cpanel/cpanel.pem

    </IfModule>
    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^cpanel\.
    RewriteCond %{HTTPS} on
    RewriteRule ^/(.*) https://127.0.0.1:2083/$1 [P]

    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^webmail\.
    RewriteCond %{HTTPS} on
    RewriteRule ^/(.*) https://127.0.0.1:2096/$1 [P]

    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^whm\.
    RewriteCond %{HTTPS} on
    RewriteRule ^/(.*) https://127.0.0.1:2087/$1 [P]

    RewriteCond %{HTTP_HOST} !^wdsl.adomain.com$
    RewriteCond %{HTTP_HOST} ^webdisk\.
    RewriteCond %{HTTPS} on
    RewriteRule ^/(.*) https://127.0.0.1:2078/$1 [P]

    UseCanonicalName Off
</VirtualHost>

#JK

LoadModule jk_module modules/mod_jk.so
JKWorkersFile /usr/local/apache/conf/workers.properties
# Where to put jk logs
JKLogLevel debug
# Select the log format
JKLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JKOptions indicate to send SSL KEY SIZE
JKOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JKRequestLogFormat set the request format
JKRequestLogFormat "%w %V %T"
# Send all xhtml requests to Glassfish
JKMount /*.xhtml worker1
# Send all domain requests to Glassfish
JKMount /domain/* worker1

<VirtualHost 0.0.0.0:80>
    ServerName sub.domain.com
    ServerAlias www.sub.domain.com
    DocumentRoot /home/sub/public_html/sub
    ServerAdmin webmaster@sub.domain.com
    UseCanonicalName Off
    CustomLog /usr/local/apache/domlogs/sub.domain.com combined
    CustomLog /usr/local/apache/domlogs/sub.domain.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
    ## User user # Needed for Cpanel::ApacheConf
    UserDir enabled user
    <IfModule mod_suphp.c>
        suPHP_UserGroup user user
    </IfModule>
    <IfModule !mod_disable_suexec.c>
        <IfModule !mod_ruid2.c>
            SuexecUserGroup user user
        </IfModule>
    </IfModule>
    <IfModule mod_ruid2.c>
        RMode config
        RUidGid user user
    </IfModule>
    <IfModule itk.c>
        # For more information on MPM ITK, please read:
        #   http://mpm-itk.sesse.net/
        AssignUserID user user
    </IfModule>
    ScriptAlias /cgi-bin/ /home/user/public_html/sub/cgi-bin/

    AccessFileName .htaccess
</VirtualHost>


<VirtualHost 0.0.0.0:80>  
  ServerAdmin admin@domain.com  
  ServerName  domain.com  

        ProxyRequests Off  
        <Proxy *>  
           Order deny,allow  
           Allow from all  
        </Proxy>
        ProxyPass / http://0.0.0.0:8080/  
        ProxyPassReverse / http://0.0.0.0:8080/  

        <Location />
        Order allow,deny
        Allow from all
        </Location>

       ErrorLog logs/glassfish-apache-error_log  
       CustomLog logs/glassfish-apache-access_log common      
</VirtualHost>

Include "/usr/local/apache/conf/includes/post_virtualhost_global.conf"
Include "/usr/local/apache/conf/includes/post_virtualhost_2.conf"

Has anyone ran into a similar error or knows how can it be fixed?

  • Blaming this particular rule doesn't seem to make much sense as it uses the L flag. What exactly makes you think it causes redirection loop? See the L flag documentation for it's meaning.

    Can you dump rewrite debug log?

  • What makes me think it causes that error is because when I comment it out the page loads but without css because it tries to find 'companion.gesht.comcss' instead of 'companion.gesht.com/css&#39;.

    [Sun Jun 29 10:05:28 2014] [error] [client 109.127.80.61] 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://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3112): [client 109.127.80.61] r->uri = /~gesht/companion/, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /~gesht/companion/index.php, referer: http://gesht.com/en/Home
    [Sun Jun 29 10:05:28 2014] [debug] core.c(3118): [client 109.127.80.61] redirected from r->uri = /index.php, referer: http://gesht.com/en/Home

     

  • You should use URL WITH trailing slash in configuration. Try changing it in DB or through admin panel if you manage and try again. If that won't help, we need rewrite debug log here.

    Edit: I see rewrite log now in post above.

  • Yes! It worked. I added a trailing slash and it now loads everything except graphics. I'll check to see why?

     

  • You have broken links for _graphics folder. Make sure it exists on server and if it does, check if you still have all RewriteCond's in your .htaccess file. Only part of the Elgg's rewrite rules that you might want to change is RewriteBase. The rest of rewrite rules must remain intact.

  • I had to add this to avoid that internal redirect error:

    RewriteCond %{ENV:REDIRECT_STATUS} ^200
    RewriteRule ^ - [L]

    Apart from that I have not modified any rules.

  • I see 302 moved temporarily errors for javascript files and images in firebug.

     

  • _graphics folder is accessible, images and scripts URLs are correct for example when I click view image on the spacer.gif image it tries to open `companion.gesht.com/_graphics/spacer.gif` but it redirects to `companion.gesht.com` and doesn't show the image. It must be caused by
    `RewriteCond %{ENV:REDIRECT_STATUS} ^200
    RewriteRule ^ - [L]`
    but if I comment this rule out I get 500 internal server error with `Request exceeded the limit of 10 internal redirects due to probable configuration error`