SSL working on root, but not on www

Set up Let’s Encrypt with multiple domains / redirects does sort-of what you want it to do. You’ll need to make some modifications. There was a another topic on the same issue recently.