How to change the root URL path of Nextcloud?

I found the solution according to Nextcloud’s official manuals.

To add a URL prefix for an existing Nextcloud installation, one should do following steps:

1: Configure the HTTP server of the existing Nextcloud installation.

Change the DocumentRoot to a dummy directory and add restrictions to the dummy directory as deny all requests.

Then add an Alias to the wanted prefix to the real directory of the existing Nextcloud installation (which should be the original DocumentRoot).

#DocumentRoot /Org/Install/Dir/
DocumentRoot /Dummy/Dir/
<Directory "/Dummy/Dir/">
  Require all denied
</Directory>
Alias "/My/Wanted/Prefix/" "/Org/Install/Dir/"

Then restart the HTTP server. And as you know, my example here is for Apache web server.

2: Configure Nextcloud’s config.php

Find the line below:
'overwrite.cli.url' => '',
change to
'overwrite.cli.url' => 'https://mycloud.example.com/My/Wanted/Prefix',

3: Configure Nextcloud Android App

Actually , I can find no way to change the existing login of the Nextcloud Android App. I managed to uninstall the Nextcloud Android App then install it back to begin the login process. Maybe there are smarter methods like delete cache and local storage etc.

Anyway, at the login place you should choose the private installation and at the URL field fill up the URL as https://mycloud.example.com/My/Wanted/Prefix

References: Nextcloud Administration Manual and Nextcloud Android Manual

1 Like