From ce99453f66fa50448e2900ef596baca85ffac093 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Sat, 10 Jun 2023 13:52:39 +0200 Subject: [PATCH 1/2] Fix .htaccess configuration to actually work The `.htaccess` rules should not have the starting slash otherwise they will never get matched. When running the mod_rewrite in .htaccess, the path is already sanitized and leading slashes stripped. Document also that this is not the case when the rules are used directly from the main apache2 configuration the leading slash is present always, which led to some edit wars of this documentation in the past as it was not well explained (#8093, #3811). This matches the code shipped with the .htaccess in the nextcloud server: https://github.com/nextcloud/server/blob/master/.htaccess Signed-off-by: Jakub Jelen --- .../issues/general_troubleshooting.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/admin_manual/issues/general_troubleshooting.rst b/admin_manual/issues/general_troubleshooting.rst index 20b46e2cca3..9e1f7b6f71a 100644 --- a/admin_manual/issues/general_troubleshooting.rst +++ b/admin_manual/issues/general_troubleshooting.rst @@ -259,14 +259,24 @@ document root of your Web server and add the following lines:: RewriteEngine on - RewriteRule ^/\.well-known/carddav /nextcloud/remote.php/dav [R=301,L] - RewriteRule ^/\.well-known/caldav /nextcloud/remote.php/dav [R=301,L] - RewriteRule ^/\.well-known/webfinger /nextcloud/index.php/.well-known/webfinger [R=301,L] - RewriteRule ^/\.well-known/nodeinfo /nextcloud/index.php/.well-known/nodeinfo [R=301,L] + RewriteRule ^\.well-known/carddav /nextcloud/remote.php/dav [R=301,L] + RewriteRule ^\.well-known/caldav /nextcloud/remote.php/dav [R=301,L] + RewriteRule ^\.well-known/webfinger /nextcloud/index.php/.well-known/webfinger [R=301,L] + RewriteRule ^\.well-known/nodeinfo /nextcloud/index.php/.well-known/nodeinfo [R=301,L] Make sure to change /nextcloud to the actual subfolder your Nextcloud instance is running in. +.. note:: Note, that if you are putting the above configureation directly to + the apache configuration (generaly in ``/etc/apache2/sites-enabled/``), + you will need to prepend the first argument of each of the above + ``RewriteRule`` option with a forward slash ``/``, for example + ``^/\.well-known/carddav``. + This is because Apache already normalizes the values for the use in + ``.htaccess`` by dropping any number of leading slashes, but it does + not for the use in its main site configuration where the forward slash + is still present. + If you are running NGINX, make sure ``location = /.well-known/carddav {`` and ``location = /.well-known/caldav {`` are properly configured as described in :doc:`../installation/nginx`, adapt to use a subfolder if necessary. Now change the URL in the client settings to just use: From 9b035bf7bcd6e3bbff6c7918ef6a48dd8a49afd1 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 15 Jun 2023 22:57:41 +0200 Subject: [PATCH 2/2] fixup Co-authored-by: MichaIng Signed-off-by: Jakub Jelen --- admin_manual/issues/general_troubleshooting.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/admin_manual/issues/general_troubleshooting.rst b/admin_manual/issues/general_troubleshooting.rst index 9e1f7b6f71a..6df1a0a8b46 100644 --- a/admin_manual/issues/general_troubleshooting.rst +++ b/admin_manual/issues/general_troubleshooting.rst @@ -267,15 +267,14 @@ document root of your Web server and add the following lines:: Make sure to change /nextcloud to the actual subfolder your Nextcloud instance is running in. -.. note:: Note, that if you are putting the above configureation directly to - the apache configuration (generaly in ``/etc/apache2/sites-enabled/``), - you will need to prepend the first argument of each of the above - ``RewriteRule`` option with a forward slash ``/``, for example +.. note:: If you put the above directives directly into an Apache + configuration file (usually within ``/etc/apache2/``) + instead of ``.htaccess``, you need to prepend the first argument of + each ``RewriteRule`` option with a forward slash ``/``, for example ``^/\.well-known/carddav``. - This is because Apache already normalizes the values for the use in - ``.htaccess`` by dropping any number of leading slashes, but it does - not for the use in its main site configuration where the forward slash - is still present. + This is because Apache normalizes paths for the use in ``.htaccess`` + files by dropping any number of leading slashes, but it does not + do so for the use in its main configuration files. If you are running NGINX, make sure ``location = /.well-known/carddav {`` and ``location = /.well-known/caldav {`` are properly configured as described in :doc:`../installation/nginx`, adapt to use a subfolder if necessary.