Random Error 500

Nextcloud version (eg, 16.0.3):
Operating system and version (linux ):
Apache or nginx version (eg, Apache 2.4.39):
PHP version (eg, 7.2.21):
cPanel: 80 (build 23)

The issue you are facing:
I host several instances of nextcloud on my shared server. each on a different subdomain., I manage my instances with softaculous.

Without me changing or updating anything, three of my 4 instances stop working today morning and now showing an error 500. I’ve had the issues some days ago, but could get them back running with updating to 16.03 through softtaculous.

My 4th instance is running because I forgot to start the last step (starting the upgrade in the webinterface). I did this now and I get the welcome screen, so its running.

All this tells me, that this error has nothing to do with a server configuration, or am I wrong. Also, I had this error before and I could help myself with reinstalling nextcloud in another folder and connecting it back to the original database and folder. But that can’t be the solution.

Is this the first time you’ve seen this error? (Y/N):

The output of your Nextcloud log in Admin > Logging:

Since I can not log in, I can not provide this

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

my config.php has no added information other than

$CONFIG = array (
  'instanceid' => 'deleted'
  'passwordsalt' => 'deleted',
  'secret' => 'deleted',
  'trusted_domains' => 
  array (
0 => 'deleted',
  'datadirectory' => 'deleted',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'deleted',
  'dbname' => 'deleted',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'deleted',
  'dbpassword' => 'deleted',
  'installed' => true,
  'theme' => '',
  'loglevel' => 2,
  'maintenance' => false,

of course ‘deleted’ means I censored this

The output of your Apache/nginx/system log in /var/log/____:
Unfortunately on my shared server I do not have access to this folder

Has someone any any of why this is happening?

Thank you so much

Well I think I figured out the problem by myself… I was looking into the nextcloud folder and saw that the .htaccess has been modified (not by me).

Here is the broken one:

text/x-generic .htaccess ( UTF-8 Unicode text )
<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1

  <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

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

  # Let browsers cache WOFF files for a week
  <FilesMatch "\.woff2?$">
    Header set Cache-Control "max-age=604800"
<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 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 mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off

ErrorDocument 403 //
ErrorDocument 404 //

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
# php -- END cPanel-generated handler, do not edit

The error is, that these lines of code are in the wrong place:

    ErrorDocument 403 //
    ErrorDocument 404 //

They shoud appear at the end of the code (as they do in my not broken instance

Has anyone an idea of why this happend?