Upgrade to 14.0.4 fails due to unwanted presence of /.well-known/ folder

I am confused. The advice from Nextcloud here in response to the setup error described here clearly refers to a folder called /.well-known/ in the root folder.
Yet on trying to upgrade to 14.0.4 this morning, the presence of this folder throws an error that cannot be ignored or skipped - the upgrade fails. My server is running Apache I believe.
I have searched online and found advice saying that one should manually move the folder to another location in order to complete the upgrade, then move it back, but this feels a bit crazy.
I have also found reference to LetsEncrypt, but I have not ever used this or installed it myself. I created the .well-known folder in order to solve the security error that Nextcloud gives relating to carddav and caldav. Seems like an inconsistency within Nextcloud as to how to solve this problem in a way that is compatible with being able to upgrade the software.
I have also seen reference to the .well-known folder being in the server root folder, but this seems wrong to me: what if you were running NC in the root folder, or if you were wanting to run more than one instance of NC on the same server, you couldn’t use the same caldav and carddav redirects within the same .htaccess file? I thought each NC instance should have its own .htaccess file?

You’re not supposed to literally create that folder, it’s a URL rewrite that is needed, not a folder. You need to put rewrite rules into your apache or nginx config to point a URL that contains .well-known to where the caldav resources really are. Apparently you can trick nextcloud by creating an actual folder but that isn’t an actual fix hah.

The caldav resource on nextcloud is located at the URL below, so any user who wants to use caldav must go to the below URL:


However, some caldav applications will ONLY go to here:


So, you need to setup a rewrite rule in a .htaccess file so that when a request comes into the webserver looking for https://example.com/.well-known/caldav, it automatically sends them to https://example.com/nextcloud/remote.php/dav.

If your nextcloud URL is www.example.com/nextcloud then in the directory below nextcloud create a new file called “.htaccess” and paste the code below into it, or if it already exists, paste the following into the existing file. And delete that actual .well-known folder you made.

RewriteEngine on
RewriteRule ^.well-known/host-meta /nextcloud/public.php?service=host-meta [QSA,L]
RewriteRule ^.well-known/host-meta.json /nextcloud/public.php?service=host-meta-json [QSA,L]
RewriteRule ^.well-known/webfinger /nextcloud/public.php?service=webfinger [QSA,L]
RewriteRule ^.well-known/carddav /nextcloud/remote.php/dav/ [R=301,L]
RewriteRule ^.well-known/caldav /nextcloud/remote.php/dav/ [R=301,L]