Htaccess RewriteBase doesn't work with own domain

Hi,

I’m trying to use the pretty url description but it broke the website completely.

I’m using the virtual host based installation on ubuntu 22.04 with php 8.2 and Apache/2.4.52
behind an F5 loadbalancer and firewall.
On F5 we do healthchecks with urls for the individua servers.

This is my apache server config and nextcloud when works:

<VirtualHost *:443>
  ServerAdmin myemail@mydomain.com
  DocumentRoot /var/www/nextcloud/
  ServerName nextcloud.mydomain.com
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory /var/www/nextcloud/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>
</VirtualHost>

SSLEngine on
SSLCertificateFile /etc/apache2/sites-available/wildcard_mydomain_com.pem
SSLCertificateKeyFile /etc/apache2/sites-available/wildcard_mydomain_com.pem
SSLCertificateChainFile /etc/apache2/sites-available/wildcard_mydomain_com.pem

The config.php at the moment like this

<?php
$CONFIG = array (
  'instanceid' => 'ocmkr9k',
  'passwordsalt' => 'dNYx0ks',
  'secret' => 'vmPezV',
  'trusted_domains' =>
  array (
    0 => 'myindividual.server1',
    1 => 'myindividual.server2',
    2 => 'nextcloud.mydomain.com',
  ),
  'datadirectory' => '/nextcloud_data',
  'overwrite.cli.url' => 'https://nextcloud.mydomain.com/',
  'overwritehost' => 'nextcloud.mydomain.com',
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'dbname' => 'nextcloud',
  'dbhost' => 'galera_ha_ip:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'user',
  'dbpassword' => 'dbpw',
  'installed' => true,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
);

When I change to the rewrite one, I add this line to the config.php:

'htaccess.RewriteBase' => '/',

Run the command:
sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess

This generates this in the .htaccess:

#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 /index.php/error/403
ErrorDocument 404 /index.php/error/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|map|webm|mp4|mp3|ogg|wav|wasm|tflite)$
  RewriteCond %{REQUEST_FILENAME} !/core/ajax/update\.php
  RewriteCond %{REQUEST_FILENAME} !/core/img/(favicon\.ico|manifest\.json)$
  RewriteCond %{REQUEST_FILENAME} !/(cron|public|remote|status)\.php
  RewriteCond %{REQUEST_FILENAME} !/ocs/v(1|2)\.php
  RewriteCond %{REQUEST_FILENAME} !/robots\.txt
  RewriteCond %{REQUEST_FILENAME} !/(ocm-provider|ocs-provider|updater)/
  RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
  RewriteCond %{REQUEST_FILENAME} !/richdocumentscode(_arm64)?/proxy.php$
  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /
  <IfModule mod_env.c>
    SetEnv front_controller_active true
    <IfModule mod_dir.c>
      DirectorySlash off
    </IfModule>
  </IfModule>
</IfModule>

And my website doesn’t load anymore.

What I’m missing?

I’m not familiar with the product but what I’m curious about is if you’re somehow able to bypass the load balancer and see if it works then.

And of course, empty the browser cache etc…