How to correctly set up NextCloud to be accessible from two different domains?

I have a NextCloud 11 server up and running. However I need to make it accessible from a new domain and leave the old domain name accessible for client compatibility purposes.

What is the best way to do it?

Old address:
New address:

Both domains have valid certificates with let’s encrypt.
I tried to point DocumentRoot in apache site conf of the new domain to the installation folder of the old, but I got weird artefacts with icons missing randomly on the webpage, so I don’t think that’s the right way to go…

Can someone give me a hint?


— sorry for my english :slight_smile:

How looks your VirtualHost file?

In my case (same config file):

and add the domain to config.php like:
array (
0 => ‘olddomain.old’,
1 => ‘newdomain.ned’,

Please make shure that the DNS resolution are correctly (from the internet)

Hope that can help.

Thanks for the answer, I almost does. I have the configuration in two dirrerent files, but that sould not matter.

The only difference is that I have;
ServerName olddomain.old
DocumentRoot /my/dir/to/old/

 DocumentRoot /my/dir/to/old/nextcloud

They both work correctly one by one, but not well together. I am not sure if I can run two servers over the same nextcloud configuration.

Souldn’t I use sime kind of redicect better?

In my case: it works with two domains correctly.

What have you by < Virtualhost XYZ > ?

You want to connect to the same Nextcloud installation with to diffrence domainnames -> correct?

<VirtualHost _default_:443>
in the old configuration

<VirtualHost *:443>

in the new one

Yes, I want to be able to access


and work

as well as

and work as well.

Please try to set by your old config, like the new. (VirtualHost *:443) -> restart the apache

what’s the name of your main-folder from nextcloud?

There is some kind of strange error, because when I switch off both of them and then just switch on the new one, it works fine.

But if I swith back on the old one and try to access it, the applicaion icons are missing…

I just tried it again, doing what you suggested, but with the same result.

Does anybody have a clue why this strange error might be happening?

I tried something

ln -s /var/www/html/nextcloud/ owncloud -> that add link to nextcloud folder.

first parameter is the real folder -> second parameter is the alias to the folder

-> old Virtualhost: eg. DocumentRoot /var/www/html/olddir/ (not nextcloud) -> add alias (into the olddir folder)

in my case works: with diffrent domains and like your old config with subfolder.

Hope that can help

I had to leave the computer for now. I’ll try your last suggestion.

Thank you for your help @ham!

Running on two different domains is no problem. But you can’t use one in a subfolder and the other not. I would try to redirect the old URL. However I’m not sure how the client reacts and if it follows redirects…

Thank you for the answers. After all I’ve decided that it’s easier to try thoroughly change all client settings rather than risk data los.

I’ll ditch the old address all together.

This should be pretty easy to do, but let me make sure I understand the goal. Do you want to serve one Nextcloud installation across two domain names? If yes, the easiest way is to add a ServerAlias directive to your existing Apache config and edit your config.php like @ham’s comment above. Here is an example of how to edit config.php from the official documentation.

You now have this in your Apache VirtualHost:
ServerName olddomain.old
So just insert this line below it and you are done:

If you follow the above steps you don’t need to worry about data loss, and the changes are easily reverted.

However if you are trying to use two Nextcloud instances, each with its own domain name, and both on one server, then you need two separate VirtualHost configurations and databases. Careful with the databases - these are where you might have data loss if you are careless!

Hi there,

very old topic but I have the same issue.
Exactly like elpraga explained and what tombrossman wrote.

I tried what tombrossmann suggested but when I do so, my internet browser warns me because of bad certificate.

What can I do?