To find out if they are reasonable I would ask the nextcloud guys. They may be placeholder directives in case you are using certain plugin of theirs or similar. Cheers El jue, 17 dic 2020 a las 19:36, Lentes, Bernd (<bernd.lentes@xxxxxxxxxxxxxxxxxxxxx>) escribió: > > > > ----- On Dec 17, 2020, at 5:19 PM, Daniel Ferradal dferradal@xxxxxxxxxx wrote: > > > Hey Bernd, > > > > I remember my first head scratches with regex, they can be so > > confusing and difficult to understand. > > > > Although I remember preciously the day https://regexone.com/ opened my > > eyes. It just took me 45 minutes to understand the basics of it. > > > > I dearly recommend you to do the same and visit the site, once you > > grasp it, regex will be tones of times easier to deal with. > > > > Cheers > > > > Hi Daniel, > > my problems are more the understanding of RewriteRule in vhost- or per-directory context. > I try to understand how rewriting works in a up-to-date Nextcloud. > > This is the scenario: > > root@nc-mcd:~# ll /var/www/nextcloud > total 116 > drwxr-x--- 1 www-data www-data 396 Dec 9 20:33 ./ > drwxr-xr-x 1 root root 90 Dec 14 19:01 ../ > drwxr-x--- 1 www-data www-data 778 Dec 9 20:33 3rdparty/ > drwxr-x--- 1 www-data www-data 1154 Dec 14 22:20 apps/ > -rw-r----- 1 www-data www-data 17234 Dec 9 20:30 AUTHORS > drwxr-x--- 1 www-data www-data 72 Dec 14 19:08 config/ > -rw-r----- 1 www-data www-data 3893 Dec 9 20:30 console.php > -rw-r----- 1 www-data www-data 34520 Dec 9 20:30 COPYING > drwxr-x--- 1 www-data www-data 458 Dec 9 20:33 core/ > -rw-r----- 1 www-data www-data 5083 Dec 9 20:30 cron.php > -rw-r----- 1 www-data www-data 4450 Dec 14 19:08 .htaccess <====== > -rw-r----- 1 www-data www-data 156 Dec 9 20:30 index.html > -rw-r----- 1 www-data www-data 2960 Dec 9 20:30 index.php > drwxr-x--- 1 www-data www-data 126 Dec 9 20:30 lib/ > -rw-r----- 1 www-data www-data 283 Dec 9 20:30 occ > drwxr-x--- 1 www-data www-data 18 Dec 9 20:30 ocm-provider/ > drwxr-x--- 1 www-data www-data 50 Dec 9 20:30 ocs/ > drwxr-x--- 1 www-data www-data 18 Dec 9 20:30 ocs-provider/ > -rw-r----- 1 www-data www-data 3102 Dec 9 20:30 public.php > -rw-r----- 1 www-data www-data 5332 Dec 9 20:30 remote.php > drwxr-x--- 1 www-data www-data 158 Dec 9 20:30 resources/ > -rw-r----- 1 www-data www-data 26 Dec 9 20:30 robots.txt > -rw-r----- 1 www-data www-data 2379 Dec 9 20:30 status.php > drwxr-x--- 1 www-data www-data 26 Dec 9 20:30 themes/ > drwxr-x--- 1 www-data www-data 42 Dec 9 20:31 updater/ > -rw-r----- 1 www-data www-data 101 Dec 9 20:30 .user.ini > -rw-r----- 1 www-data www-data 362 Dec 9 20:33 version.php > > There is a .htaccess in the folder. > So per-directory context. Now from the official apache documentation: > > What is matched ? > ... > "In per-directory context (Directory and .htaccess), the Pattern is matched against only a partial path, for example a request of "/app1/index.html" may result in comparison against "app1/index.html" or "index.html" depending on where the RewriteRule is defined. > The directory path where the rule is defined is stripped from the currently mapped filesystem path before comparison (up to and including a trailing slash)." > > So in this case this would mean, as the .htaccess file is in /var/www/nextcloud/, this path (/var/www/nextcloud/) is stripped before comparing. > > "The net result of this per-directory prefix stripping is that rules in this context only match against =====> the portion of the currently mapped FILESYSTEM PATH "below" <======= where the rule is defined. > I understand it that way that a request of /somepath/somefile, which mapps maybe via an alias to /var/www/nextcloud/ looks now IN THE FILESYSTEM for somepath/somefile below /var/www/nextcloud/ > That's my understanding and afters hours of fighting with rewrite i was happy and proud to get it. But ... > > Here are the some rewriterules from that .htaccess: > > RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L] > RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L] > RewriteRule ^\.well-known/webfinger /public.php?service=webfinger [QSA,L] > RewriteRule ^\.well-known/nodeinfo /public.php?service=nodeinfo [QSA,L] > RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L] > RewriteRule ^\.well-known/caldav /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] > > Let's take the first rule: > RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L] > Following my assumption (the rule is defined in a .htaccess in /var/www/nextcloud, so /var/www/nextcloud/ is stripped), the pattern '^\.well-known/host-meta' is matched again the filesystem "below" the .htaccess. > But there is no folder ".well-known. > And the other rules: there are no folders remote/, no folder or file named build, tests, config, lib, ... > Then all these rules wouldn't make sense !?! > > I thought i got it, but now i'm completely stunned. > Can someone bring light into it ? Is my understanding wrong, that in per-directory context the pattern is matched against the fs ? Although the doc says it ? > > Thanks. > > > Bernd > Helmholtz Zentrum München > > Helmholtz Zentrum Muenchen > Deutsches Forschungszentrum fuer Gesundheit und Umwelt (GmbH) > Ingolstaedter Landstr. 1 > 85764 Neuherberg > www.helmholtz-muenchen.de > Aufsichtsratsvorsitzende: MinDir.in Prof. Dr. Veronika von Messling > Geschaeftsfuehrung: Prof. Dr. med. Dr. h.c. Matthias Tschoep, Kerstin Guenther > Registergericht: Amtsgericht Muenchen HRB 6466 > USt-IdNr: DE 129521671 > -- Daniel Ferradal HTTPD Project #httpd help at Freenode --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx