I've been trying to use Apache RedirectMatch to send most requests to SSL, but still allowing the Lets Encrypt challenge to work:
RedirectMatch permanent ^/(?!\.well\-known/acme\-challenge)(.*)$ https://example.com/$1
This redirects the bare domain, example.com, to https://example.com. It also allows through the Lets Encrypt challenge without redirection. But it fails to redirect anything that is more than just the domain, so e.g. example.com/page goes to page, but not SSL.
Regex tests suggest that it should work, but it doesn't. Any suggestions?