My server has IPv6 address, but as IPv6 does not work properly in some networks, I have created a sub-domain, which has only IPv4 address, and it points to the same IP as my server. This all is to serve my Nextcloud installation.
On the server, both names (server.org and subdomain.server.org) are served from the same directory tree. Both of them work fine, except for RewriteRules.
I have RewriteRules on .htaccess to handle .well-known/carddav etc things, and those rules work fine on my main domain, but not for the subdomain. Here is the .htaccess file:
<IfModule mod_rewrite.c>
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]
</IfModule>
I have tried to add these RewriteRules to /etc/apache2/sites-enabled/subdomain-le-ssl.conf
, but it does not matter either. I just get 404 Not found.
MrWhite's comment had clue to the answer.
About .htaccess overrides, the line "AllowOverride All" was only on main domain's conf file. When I added it also to subdomain's conf file, RewriteRules started working. Thank you!