Migration from Apache 2.2 to Apache 2.4 AH00124: Request exceeded the limit of 10

Hi there.

I am not sure if I chose the right category, since years NC is working, but only with Apache 2.2
I am facing the issue of some errors that would prevent the NC page to load.
When running NC on Apache 2.2 as I did until today everything works fine (I know shame on me, but this current issue stopped me from updating until now). With Apache 2.2 I get currently no errors in my “error level” apache log.

When I switch to Apache 2.4.39 my NC installation is broken, without .htaccess it works.

I run the whole installation on a

  • Synology NAS (718+ @ DSN 6.2.2)
  • with Apache 2.2,
  • PHP7.2 and
  • MariaDB10.
  • Folder path is /volume1/web/owncloud/, in which /volume1/web/ is the root folder for the apache.

I googled already for the error and I tried some things like

  • regenerate the .htaccess with occ command
  • checked if the needed modules are enabled - afaik they are
  • no fault without .htaccess, I assume there is the fault

Here some links:
Request exceeded the limit of 10 internal redirects <-- I didn’t understand how to match this to my issue or to adapt the solution
Apache rewrite to remove index.php <-- this seems not to work for me

My browser shows me the error message:

Browser Errormessage

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Then I had a closer look to my httpd.log and saw the following (debug log level):

Apache 2.4 Debuglog - I had to change the : after in the link to _ to match the board rules
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.866430 2019] [authz_core:debug] [pid 7030:tid 139873923098368] mod_authz_core.c(820): [client 192.168.178.2:50642] AH01626: authorization result of Require all granted: granted, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.866460 2019] [authz_core:debug] [pid 7030:tid 139873923098368] mod_authz_core.c(820): [client 192.168.178.2:50642] AH01626: authorization result of <RequireAny>: granted, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867557 2019] [core:error] [pid 7030:tid 139873923098368] [client 192.168.178.2:50642] AH00124: 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: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867577 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3833): [client 192.168.178.2:50642] AH00121: r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867583 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867587 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867591 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867595 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867599 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867603 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867607 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867611 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867615 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867619 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /login, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867627 2019] [core:error] [pid 7030:tid 139873923098368] [client 192.168.178.2:50642] AH00124: 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: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867632 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3833): [client 192.168.178.2:50642] AH00121: r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867636 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867640 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867644 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867647 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867651 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867655 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867661 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867665 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867669 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /owncloud/index.php, referer: https_//my.daomain.tld/login
2019-10-07T18:06:16+02:00 Internet [Mon Oct 07 18:06:16.867673 2019] [core:debug] [pid 7030:tid 139873923098368] core.c(3840): [client 192.168.178.2:50642] AH00122: redirected from r->uri = /login, referer: https_//my.daomain.tld/login
This is my current NC config
<?php
$CONFIG = array (
  'instanceid' => 'dontcare',
  'passwordsalt' => 'about',
  'secret' => 'it',
  'trusted_domains' =>
  array (
    0 => 'my.domain.tld',
    1 => 'cloud.domain.tld',      <<--- mainly used, each has a own vhost, this one runs currently with Apache 2.2
    2 => 'nextcloud.domain.tld', <<--- formerly used, this one runs (not properly) currently with vhost @ apache 2.4
  ),
  'datadirectory' => '/volume1/owncloud_data',
  'overwrite.cli.url' => 'https://cloud.domain.tld/',
  'dbtype' => 'mysql',
  'version' => '16.0.4.1',
  'dbname' => 'owncloud',
  'dbhost' => '127.0.0.1:3307',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'owncloud',
  'dbpassword' => 'somethingyouwannaknow-right?',
  'logtimezone' => 'UTC',
  'installed' => true,
  'mail_from_address' => 'owncloud',
  'mail_smtpmode' => 'smtp',
  'mail_domain' => 'domain.tld',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'loglevel' => 0,
  'theme' => '',
  'enable_certificate_management' => false,
  'maintenance' => false,
  'htaccess.RewriteBase' => '/owncloud',
  'updater.release.channel' => 'stable',
  'updater.secret' => 'nothingyoushouldbeinteresedin',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'mail.domain.tld',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'generic',
  'mail_smtppassword' => 'somthinga',
  'mysql.utf8mb4' => true,
  'app_install_overwrite' =>
  array (
0 => 'admin_notifications',
1 => 'initialcheck',
  ),
);
Current .htacces
<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Download-Options "noopen"
    Header set X-Permitted-Cross-Domain-Policies "none"
    Header set Referrer-Policy "no-referrer"
    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for static resources
  <FilesMatch "\.(css|js|svg|gif)$">
    Header set Cache-Control "max-age=15778463"
  </FilesMatch>

  # Let browsers cache WOFF files for a week
  <FilesMatch "\.woff2?$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>
<IfModule mod_php7.c>
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_USER_AGENT}  DavClnt
  RewriteRule ^$         /remote.php/webdav/          [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
  RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
  RewriteRule ^\.well-known/webfinger /public.php?service=webfinger [QSA,L]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
  RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 /
ErrorDocument 404 /
<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
  RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
  RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg)$
  RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
  RewriteCond %{REQUEST_FILENAME} !core/img/manifest.json$
  RewriteCond %{REQUEST_FILENAME} !/remote.php
  RewriteCond %{REQUEST_FILENAME} !/public.php
  RewriteCond %{REQUEST_FILENAME} !/cron.php
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
  RewriteCond %{REQUEST_FILENAME} !/status.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
 RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
  RewriteCond %{REQUEST_FILENAME} !/robots.txt
  RewriteCond %{REQUEST_FILENAME} !/updater/
  RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
  RewriteCond %{REQUEST_FILENAME} !/ocm-provider/
  RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /owncloud
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>
httpd24.conf
ServerRoot "/usr/local/etc/apache24"

Listen 127.0.0.1:915

LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule asis_module modules/mod_asis.so
LoadModule cgid_module modules/mod_cgid.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule unixd_module modules/mod_unixd.so

<IfModule unixd_module>
    User http
    Group http
</IfModule>

ErrorLog /run/apache24-error_log
TraceEnable off
LogLevel debug

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

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

    CustomLog /dev/null combined
    #CustomLog /run/apache24-access_log combined
</IfModule>

<IfModule cgid_module>
    ScriptSock /run/httpd/user-cgisock
</IfModule>

<IfModule mime_module>
    TypesConfig conf/mime.types
    AddEncoding x-compress Z
    AddEncoding x-gzip gz tgz
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType image/x-icon .ico
    AddHandler cgi-script .cgi
</IfModule>

MIMEMagicFile conf/magic
EnableMMAP off

# TODO: AllowOverride of root directory to All ??
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

# TODO: should apache handle this or nginx?
<IfModule deflate_module>
    DeflateCompressionLevel 2
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    AddOutputFilter DEFLATE js css
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.[0678] no-gzip
    BrowserMatch \bMSIE\s7  !no-gzip !gzip-only-text/html
</IfModule>

# TODO: should apache handle this or nginx
<Files ~ "^\.([Hh][Tt]|[Dd][Ss]_[Ss])">
    <IfModule authz_core_module>
        Require all denied
    </IfModule>
</Files>

<VirtualHost _default_:80 _default_:443>
    DocumentRoot "/var/services/web"
    Alias /_webstation_/ "/var/packages/WebStation/target/error_page/"
</VirtualHost>

# TODO: Should apapche handle FileETag
# For CVE-2003-1418
FileETag MTime Size

Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-languages.conf
Include conf/extra/mod_xsendfile.conf
Include conf/extra/mod_rpaf.conf

IncludeOptional sites-enabled/*.conf
httpd-vhosts.conf
alias /_webstation_/ "/var/packages/WebStation/target/error_page/"
ErrorDocument 400 /_webstation_/400.html
ErrorDocument 401 /_webstation_/401.html
ErrorDocument 402 /_webstation_/402.html
ErrorDocument 403 /_webstation_/403.html
ErrorDocument 404 /_webstation_/404.html
ErrorDocument 405 /_webstation_/405.html
ErrorDocument 406 /_webstation_/406.html
ErrorDocument 407 /_webstation_/407.html
ErrorDocument 408 /_webstation_/408.html
ErrorDocument 500 /_webstation_/500.html
ErrorDocument 501 /_webstation_/501.html
ErrorDocument 502 /_webstation_/502.html
ErrorDocument 503 /_webstation_/503.html
ErrorDocument 504 /_webstation_/504.html
ErrorDocument 505 /_webstation_/505.html

<VirtualHost *:80 *:443>
    ServerName nextcloud.domain.tld
    SetEnv HOST onextcloud.domain.tld
    DocumentRoot "/volume1/web/owncloud"
    <IfModule dir_module>
        DirectoryIndex  index.html index.htm index.cgi index.php index.php5
    </IfModule>
    <Directory "/volume1/web/owncloud">
        Options MultiViews FollowSymLinks ExecCGI
        AllowOverride All
        <IfModule authz_core_module>
            Require all granted
        </IfModule>
    </Directory>

    <FilesMatch "\.(php[345]?|phtml)$">
        SetHandler "proxy:unix:/run/php-fpm/php-960bb595-b815-4b96-b3b2-6d422bc7bf34.sock|fcgi://localhost"

    </FilesMatch>
</VirtualHost>

Edit:
After I have slept on it, I found out, that the rewrite base in .htaccess should be wrong.

<IfModule mod_rewrite.c>
....      
   RewriteBase /owncloud
....

When I change RewriteBase /owncloud to RewriteBase / everything works again. I assume that this .htaccess is generated in a way that it assumes that the .htaccess is located a folder above the nextcloud folder. The reason that my nextcloud folder is called owncloud is historical, I started to run my cloud service with OC 5.0.