How to change the root URL path of Nextcloud?

I installed a Nextcloud server for my family only. I want to mitigate the probing from the internet by prefix the Nextcloud root URL path.

Give 2 examples:

  1. from to
  2. from to

If the visitors access to incorrect prefix, then the web server will return the 403. The web server configurations are not the problems to me, but I need to know how to configure the nextclound’s config.php for this. And also how to configure this prefix to the Nextcloud Android App.

1 Like

I think it is because of rewrite in nextcloud not possible. Use perhaps two subdomains. Rewrite is in .htaccess

So, I suppose that Nextcloud doesn’t have such feature. This tells me that I need to issue a feature request.

You can install Nextcloud in sub dirs e.g. https://cloud.server.tld/path/

1 Like

Then do you know how can I change this for an existing installation ?

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
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' => '',

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

References: Nextcloud Administration Manual and Nextcloud Android Manual

1 Like