'How to apply LetsEncrypt SSL certificate to WWW domain?

I am using a Hostinger VPS and Hestia CP. I can create LetsEncrypt SSL from the control panel which successfully applies to https://example.com.

It also works perfectly when I go to www.example.com in Google Chrome, Opera, and Microsoft Edge.

However, www.example.com gives "SSL_ERROR_BAD_CERT_DOMAIN" on Firefox and Internet Explorer.

www.example.com actually redirects to https://example.com address anyway but for some reason, Firefox and IE don't redirect the website before the error.

So I am assuming that it leaves me with two options. Either use the SSL certificate for both www and non-www domains or find a solution to redirect the website before the error. Couldn't figure out which way is better and how to do them tho.



Solution 1:[1]

If you create a new domain, it is important to also add www. subdomain to alias column. So, f.e. like on the screenshot bellow.

enter image description here

The next what you will do is (re)generating SSL. Now, when you generate it after the entering the alias(es), the SSL cert. will be generated also with them.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Samuel Krempaský