Nextcloud redirects me to first URL

I want to use nextcloud with two different URLs. I changed the trusted domains in my config.php and set ‘overwritehost’ => ‘’, added my new domain in the Caddyfile.
But it always redirects me to my main url when I want to connect on the new one.
Does anybody have an idea what I need to change?

I am running Nextcloud 31.0.5 using Nextcloud aio 11.0.0, behind caddy as a reverse proxy.

Hi, see Allow for multiple NC_DOMAIN domain names · nextcloud/all-in-one · Discussion #2598 · GitHub

After looking a bit more into it it looks like:

  • Multiple domains are not supported and won’t be github
  • Your suggestion is to create two instances of nc aio, a different one for each domain, but I want my one nextcloud instance to be available under two domains
  • It might be possible to achieve that using a manual setup and changing the latest.yml github, according to your link and suggestion, but then you will lose the aio interface, update and backup capabilities

I got so far as changing the config.php in my nextcloud instance (github) so that overwritehost=‘’ is not set, and now I can access my nexcloud on my domain when I append /apps/files/ to my domain name. It still redirects on login and occasionally, but going back to the second domain works for a while. Thats fine for me as the second domain is mostly for emergency situations, and it seems like more is impossible.

Thanks for your fast answer