I have my site at a host and my domain with a registrar. I have a subdomain pointed to my hosted site via an A record.
From the beginning. I am using cloudways hosting. I set up my site. (A wordpress site.) I then went to my registrar and set up an A record to point to my site. It worked. The A record was simply sub.example.c om. I then tested that url and it worked. So I made a second A record for www.sub.example.c om so I could be able to get to my site with or without www. The www worked. So far so good.
Since I had everything working I decided to set up my SSL. CloudWays has Let's Encrypt integration. So ithas the option to set it up for you. I set it up and went to https://sub.example.com. It worked. I then went to https://www.sub.example.com. and got a certificate error. I didn't think about it when I set up the cert, but I used sub.example.com. So it makes sense the site only works without the www.
Since Let's Encrypt doesn't do wildcard certs I need a work around. Is there a way I can forward https://www.mysub to https://mysub? using mod rewrite? Or any other way?