I'm trying to prepare for the upcoming Chrome "Non Secure display" v56 release.
I run a website service: example.com
I give each customer a sub domain off the service: cust1.example.com
, cust2.example.com
, etc.
Years ago I configured the service to accept www.cust1.example.com
, www.cust2.example.com
, etc. Primarily because customers always added the "www" to the front of everything. I wanted to make sure they got their site and not an "invalid domain" message.
I purchased a wildcard SSL certificate *.example.com
to cover customer sites. Obviously this does not work for www.cust1.example.com
, etc. Most of my customers have not used HTTPS so this has not been a problem.
With the modern browsers forcing https now it is becoming a problem.
I have tried using mod_rewrite to fix the problem.
RewriteCond %{HTTP_HOST} ^www\.([^\.]+)\.example\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ https://%1.example.com/$1 [R=302,E=nocache:1,L]
Note: I'm using 302 while I test a solution so I don't accidentally push a redirect into the browser's cache and can never change it again.
The problem is when you start with HTTPS in the browser, the redirect provided back from the server still triggers the ERR_CERT_COMMON_NAME_INVALID error before it can redirect to remove the "www" and get to a page with a valid certificate.
How can I remove the "www" prefix on HTTPS traffic without triggering the browser's Not Secure response?