Pretty URLs behind reverse proxy

system information

Nextcloud version (eg, 26.0.1): 27.0.0.8
Operating system and version (eg, Ubuntu 22.04): Debian 11 (5.10.0-21-amd64)
Apache or nginx version (eg, Apache 2.4.25): 2.4.56
PHP version (eg, 8.1): 8.2
Database (sqlite or MariaDB or Postgres) maria DB
Docker (compose) no
Snap no
Is this the first time you’ve seen this error? yes
config.php
$CONFIG = array (
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'REDACTED',
    2 => '192.168.178.144',
    3 => 'REDACTED',
  ),
  'trusted_proxies' =>
  array (
    0 => '127.0.0.1',
    1 => '172.17.0.0/24',
    2 => '0.0.0.0',
    3 => '192.168.178.144',
    4 => '192.168.178.0/24',
  ),
  'forwarded_for_headers' =>
  array (
    0 => 'HTTP_X_FORWARDED',
    1 => 'HTTP_FORWARDED_FOR',
  ),
  'datadirectory' => '/media/array/owncloud',
  'dbtype' => 'mysql',
  'version' => '27.0.0.8',
  'dbname' => 'owncloud',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'REDACTED',
  'dbpassword' => 'REDACTED',
  'logtimezone' => 'UTC',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'mail_domain' => 'REDACTED',
  'mail_from_address' => 'owncloud',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'REDACTED',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'loglevel' => 2,
  'debug' => false,
  'theme' => '',
  'maintenance' => false,
  'has_rebuilt_cache' => true,
  'allow_user_to_change_mail_address' => '',
  'remember_login_cookie_lifetime' => 1296000,
  'session_lifetime' => 86400,
  'mysql.utf8mb4' => true,
  'default_phone_region' => 'DE',
  'overwrite.cli.url' => 'REDACTED',
  'htaccess.RewriteBase' => '/',
  'app_install_overwrite' =>
  array (
    0 => 'news',
    1 => 'camerarawpreviews',
  ),
);

The issue you are facing:

I did everything in the guide to activate pretty URL:

  'htaccess.RewriteBase' => '/',
  'overwrite.cli.url' => 'REDACTED',

I ran the command, too. I now have these lines in my .htaccess file:

  RewriteRule . index.php [PT,E=PATH_INFO:$1]
  RewriteBase /

So everything looks good to me. However if I manually remove the index.php part from the URL, I get something like this (e.g.: the news app):
grafik

I don’t know if this is related to my nextcloud server beeing behind a reverse proxy, but I set the config.php parameters for it, so I don’t know. However nextcloud always uses index.php as part of links… So some setting has to be wrong right?

Seems a silly question, but are you using php-fpm? php-fpm cannot use .htaccess but instead uses another .user.ini or something.

I am using a different RewriteRule in Apache. This one works for me.:

RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=Permanent]

Have you also added:

RewriteEngine on

In your vhost file for Nextcloud?

No I am not running php-fpm(should I?), but mod_php.
This is my entire .htaccess file:

  <FilesMatch "\.woff2?$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>

<IfModule mod_php.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_mime.c>
  AddType image/svg+xml svg svgz
  AddType application/wasm wasm
  AddEncoding gzip svgz
  # Serve ESM javascript files (.mjs) with correct mime type
  AddType text/javascript js mjs
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule pagespeed_module>
  ModPagespeed Off
</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/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]
  RewriteRule ^\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
  RewriteRule ^(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>

AddDefaultCharset utf-8
Options -Indexes
#### 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|tfl>  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>

There are 2 IfModule mod_rewrite.c areas. Do they conflict? Do I have to add the RewriteEngine on to both?