So this is obviously a 2x2 matrix - www and non-www, against SSL and non-SSL.

I want all traffic to be directed to SSL and www.

Getting http://example.com and http://www.example.com over to https://www.example.com is simple; I just add this line in the <VirtualHost *.80> container:

Redirect / https://www.example.com

And it works. The problem is getting https://example.com over to https://www.example.com. I don't have a digital certificate for example.com - the cert is written for www.example.com!

I'm thinking anything I put inside the <VirtualHost *.443> wrapper (Rewrite Rules etc.) won't help because the cert validity is checked first. I'm wanting the redirect to happen BEFORE I get the scary-looking message below. How would I do this?

standard Chrome message for irregular cert

  • Which OS/version do you run apache on? – Anubioz Jul 14 at 8:53

As the certificate doesn't cover example.com, you need a separate VirtualHost for your example.com:443. With SNI it can have another certificate for example.com, e.g. free certificate from Let's Encrypt. You simply can't get rid of the error without a matching certificate.

  • I did do a separate VirtualHost container with example.com:443, but of course there's no cert. What does SNI mean? – Oliver Williams Jul 14 at 1:41
  • There must be a matching certificate. Server Name Indication SNI is a TLS extension that enables you to have multiple certificates on a single IP address i.e. with VirtualHosts. It's explained e.g. by Cloudflare and GlobalSign. For millenials there's even videos on YouTube. – Esa Jokinen Jul 14 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.