I purchased a wildcard for the following domain = *.example.com
My website URL is = https://sub.example.com
I configured redirections through apache2 VirtualHosts like this (to force "http" to "https", and "www" to "no-www") =
<VirtualHost *:80>
ServerName sub.example.com
ServerAlias www.sub.example.com
ServerAdmin webmaster@example.com
# Redirect 301 to HTTPS
Redirect permanent / https://sub.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName sub.example.com
ServerAlias www.sub.example.com
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html/example
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Redirect www to no-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# TLS
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/wildcard.crt
SSLCertificateKeyFile /etc/apache2/ssl/wildcard.key
SSLCertificateChainFile /etc/apache2/ssl/digicert.pem
Header always set Strict-Transport-Security "max-age=15768000"
</VirtualHost>
Redirects are working fine for http (80) requests =
http://sub.example.com
tohttps://sub.example.com
==> WORKShttp://www.sub.example.com
tohttps://sub.example.com
==> WORKS
But not for https (443) requests with "www" =
https://www.sub.example.com
tohttps://sub.example.com
==> ERROR
The browser returns the following error = NET::ERR_CERT_COMMON_NAME_INVALID
During my researches, I found that some people get the same problem and the provided solution is to take a wildcard to cover the "www" part.
This is my case, I have a wildcard.
Could someone tell me why I got this error ?