/.well-known/caldav AND .htaccess

ERROR:

Your web server is not properly set up to resolve “/.well-known/caldav”. Further information can be found in the documentation.

My .htaccess file almost matches the documented solution, but my file has some extra stuff.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_USER_AGENT} DavClnt
  RewriteRule ^$ /nextcloud/remote.php/webdav/ [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  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/nodeinfo /nextcloud/public.php?service=nodeinfo [QSA,L]
  RewriteRule ^\.well-known/carddav /nextcloud/remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /nextcloud/remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
  RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>

What is the correct configuration?

1 Like

The problem is that the .htaccess is in https://example.com/nextcloud, it can only work for the directory itself or the subdirectory. You need to add this to the parent (because https://example.com/.well-known/carddav is used, and this doesn’t check the .htaccess in the nextcloud folder).

Either add a .htaccess in the rootDirectory of the domain, or add it directly to your apache-config.

Still have the problem…
I placed the file at both locations:
/var/www/.htaccess
/var/www/nextcloud/.htaccess

SOLUTION:

Edit File:
/etc/apache2/sites-enabled/default-ssl.conf

Add lines between </VirtualHost> and </IfModule>:

Redirect 301 /.well-known/carddav /nextcloud/remote.php/dav
Redirect 301 /.well-known/caldav /nextcloud/remote.php/dav

Example:
image

2 Likes