Greetings, I have the following problem and I hope you have some useful tips.
I have an external domain that I would like to forward to another domain on which my Nextcloud is running. With the current configuration, this also works perfectly in the browser or on the desktop app. Unfortunately, no connection is possible via the mobile app “server not found”. The connection can only be established if you change the external domain with www. i.e. www.domain.tld calls, if you only call domain.tld it doesn’t work in the mobile app (Android for me).
For the basic structure, the external domain refers to a server that refers to the www variant of the domain with a redirect 301. Subsequently, the www.domain.tld is referred to the www.2domain.tld (on which the Nextcloud server runs) via a CNAME entry.
I think for the Nextcloud app you must use the destination servername.
But if it works please do not use it with Redirect 301.
If you want use e.g. two names, you must configure Nextcloud to use both domain names.
This is no problem with e.g. CNAME, apache2 virtual hosts and Nextclood config/config.php .
But not with Redirect 301 and .htaccess (mod_rewrite).
I think @devnull is right and the rederct causes the issue with the app, and I’m not sure if there is good solution for this. But using diffrent names for browser and app isn’t a good solution either.
I would choose a more descriptive subdomain, such as cloud.domnain.tld and then use that everywhere. This way you do not need to do any redirect shenanigens and do not have to use www as a subdomain either, which honestly would bother me too. This has also the advantage, that if you want to host additional services under your main domain later down the road, you can just add more subdomains and CNAME records.