Serving a apache website via https:// => how can I disable the certificate/SSL handshake on the WWW version only?

Hi we use SSL on the https://www version of our website

Now I would like to disable the SSL connection on the https://non-www version of our website

SO the result is:

question: Can this be done?

ps. I am asking because nowadays more websites move to https, not realizing that directing non-www to www traffic (and vice versa) is a little more difficult - because the handshake occurs before the htaccess (rewrite) directives .. the solution is ofcourse an extra certificate ... but a better solution would be to do find a solution to just redirect the traffic ...

Appreciate your help

marked as duplicate by MadHatter, Hyppy, Xavier Lucas, Rex, Jenny D Feb 7 '15 at 16:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Yes? I was reading this article and it does cover SSL/virtualhost - I think my question is more related to how can I detect a www-version on a 443 port accept and then if/else to ssl no or ssl yes – snh_nl Feb 6 '15 at 11:07
  • 3
    You can't. If the browser expects to have an SSL conversation you don't get to override that without the browser throwing a hissy fit for the user, and rightly so. You can choose the flavour of fit (connection refused, SSL negotiation error, certificate error) but not its existence. – MadHatter Feb 6 '15 at 11:15
  • In other words, the way to do this is to have them on separate IP addresses. – Jenny D Feb 7 '15 at 16:34
  • @JennyD I hear you (and drookie, below), but that still won't do what I believe the OP wants, ie rewrites from https://sitename to http://sitename without any SSL errors. – MadHatter Feb 9 '15 at 8:08
  • @MadHatter My parser got caught up in "not wanting SSL handshake", I think. – Jenny D Feb 9 '15 at 8:39

Set up two virtual hosts: the one with www without SSL and the one without www - with both SSL and plain HTTP.

Update: @MadHatter is right, you'l need 2 IP addresses to separate http and https.

  • I am trying to figure this one out. How would I do this on IP/domain level? – snh_nl Feb 6 '15 at 11:25
  • Easily. It can be done using only one IP - this it what virtualhosts are for. – drookie Feb 6 '15 at 11:30
  • 1
    But then when people visit https://www the IP will still resolve, and they'll connect to port 443, which will have a listener - then get an SSL certificate error, surely. – MadHatter Feb 6 '15 at 13:19
  • I agree. I changed the answer. – drookie Feb 6 '15 at 13:43
  • That still won't do what the OP asks, ie rewrites. All you'll get is a "connection refused" error because there won't be a port-443 listener on the www IP address, no? – MadHatter Feb 6 '15 at 16:47

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