Nextcloud 13 pretty urls not working

As the topic subject says i can’t get pretty urls to work for my configuration. I have tried to solve this issue by reading other similar topics on this forum but couldn’t find a solution.

Goal URL rewrite raw addresses e.g. ‘https://subdomain.mydomain.com/index.php/apps/files/?dir=/&fileid=185’ to ‘https://subdomain.mydomain.com’.

[Server configuration]

  • Ubuntu 16.04.4 LTS
  • Apache 2.4.18
    . Php7_module
    . Env_module
    . Rewrite_modules
    . Other recommended modules

[Nextcloud]

  • Version: 13.0.3.2

  • Installation directory: /var/www/nextcloud

  • ‘/var/www/nextcloud/.htaccess’ is writeable by www-data

  • ‘/var/www/nextcloud/config/config.php’ pretty url parameter:
    . ‘overwrite.cli.url’ => ‘https://subdomain.mydomain.com’,
    . ‘htaccess.RewriteBase’ => ‘/’,

  • sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
    . returns positive result

  • ‘/var/www/nextcloud/.htaccess’ contains

    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"
      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 "\.woff$">
      Header set Cache-Control "max-age=604800"
    </FilesMatch>
    

continues:

<IfModule mod_php5.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  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/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|woff|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_URI} !^/.well-known/(acme-challenge|pki-validation)/.*
  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>

Remarks:

  • All HTTP request are redirect to HTTPS
  • Nextcloud server is behind a seperate ubuntu server with apache reverseproxy (SSL Certs are included)
    . ProxyPass & ProxPassReverse use ‘/ https://subdomain.mydomain.com/’

Are you sure that your .htaccess is working.

Exemple modify in your htaccess the php max upload size to something like 1024 MB. Save. do an occ maintenance:update:htaccess.

Refresh your web browser and go to the admin page and see if you see 512MB or 1024MB for max file upload.

If you still see 512MB it means that your webserver don’t read your htaccess.
Do you have the good <Directory /…> commands in your apache nextcloud.conf ?

Something like this inside your nextcloud.conf :

<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All

Dav off

SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud

I feel kinda stupid asking this but where can i find the max upload size counter on the admin page. so far i have been working most of the time in a terminal.

This is my Apache2 site configuration nextcloud.conf:
<VirtualHost *:80>
ServerName subdomain.mydomain.com
ServerAlias subdomain2.mydomain.com
DocumentRoot /var/www/nextcloud

#Redirrect from http to https
#RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteEngine on
RewriteCond %{SERVER_NAME} =subdomain.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =subdomain2.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

<VirtualHost *:443>
ServerName subdomain.mydomain.com
ServerAlias subdomain2.mydomain.com
DocumentRoot /var/www/nextcloud/

<Directory /var/www/owncloud/>
Options +FollowSymlinks
AllowOverride All

Dav off

SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud

Satisfy Any

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/subdomain.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.mydomain.com/privkey.pem

Remark: while looking for the max upload size i tried to upload a way to big file 3.4GB. With the hoops to get a error telling me the max upload size but it resulted in uploading the file.

As i can read the <Directory /var/www/owncloud/>

Says that your web files are in /var/www/owncloud but later in the doc it says /var/www/nextcloud.

You have to tell the truth, if not apache2 won’t work correctly.

I don’t see

< /Directory >

, it’s a problem of copy/paste your file ?

The owncloud is a typo and i changed it but still no success.
Dont worry i am not using owncloud and asking questions on the nextcloud forum :slight_smile:

This my apache2 conf atm (included with )
<VirtualHost *:80>
ServerName subdomain.mydomain.com
ServerAlias subdomain2.mydomain.com
DocumentRoot /var/www/nextcloud

#Redirrect from http to https
#RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteEngine on
RewriteCond %{SERVER_NAME} =subdomain.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =subdomain2.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

<VirtualHost *:443>
ServerName subdomain.mydomain.com
ServerAlias subdomain2.mydomain.com
DocumentRoot /var/www/nextcloud

<Directory /var/www/nextcloud>
Options +FollowSymlinks
AllowOverride All

Dav off

SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud

Satisfy Any
< / Directory>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/subdomain.mydomain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.mydomain.com/privkey.pem

For me you’re nextcloud.conf looks good
so modify in your htaccess file this :
php_value upload_max_filesize 511M to php_value upload_max_filesize 1024M

Save, and do what i asked first.
It’s into Admin Panel -> More Parameters (i’m on the french version)

Modified .htaccess php max upload from 511 to 1024. Went to Admin Panel -> Additional settings and maximum upload size value is ‘1 GB’

Just a question: What is not working, did you try to remove the index.php-part from your URL and it returns an error?
https://subdomain.example.com/index.php/apps/files
-> https://subdomain.example.com/apps/files

Furthermore, can you try without the reverse proxy first? Could be that there is some caching (browser, proxy, webserver)

So the .htaccess file works,
Usually i take a web browser that i never went on my cloud before and type the url :
https://cloud.mydomain.net for exemple
And after the return key i look if the url gets the index.php.