The default rule used by Virtualmin for a modern Ubuntu based Apache Virtualmin server is:
RedirectMatch ^/(?!.well-known)(.*)$ https://example.com/$1
The catch is you can’t just put this anywhere – you have to put it in the HTTP section. So if you see this at the end of the HTTP section, you’re on the right track:
RedirectMatch ^/(?!.well-known)(.*)$ https://example.com/$1 Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi </VirtualHost>