I tested this on my apache 2.2.14 instance and it worked fine:
Use the NameVirtualHost directive (to ports.conf):
NameVirtualHost *:443
define your vhosts:
<VirtualHost *:443>
ServerName www.siteA.com
DocumentRoot "/opt/apache22/htdocs/siteA"
SSLCertificateFile "/path/to/my/cert"
SSLCertificateKeyFile "/path/to/my/key"
</VirtualHost>
<VirtualHost *:443>
ServerName www.siteB.com
DocumentRoot "/opt/apache22/htdocs/siteB"
SSLCertificateFile "/path/to/my/cert"
SSLCertificateKeyFile "/path/to/my/key"
</VirtualHost>
I used this link as a resource.
SSL trafic can not work on same port as non-SSL traffic, TLS can do that but it is not used on web servers TLS is mostls used on SMTP server precisesly because of that reason
The same question was already asked several times (see two examples beneath) by different people, and it was always said, it is not possible by using Apache alone, you would have to use some other software or make your own listener of some kind:
Apache2 Rewrite http to https on port 5553
Apache answer both HTTP and HTTPS on the same port
Also I could not find any official Apache document that mentions http and https traffic on same port without some redirecting.
Keep in mind that when people say SSL they usually mean SSL/TLS which are not the same.
I would take this answer from apache.org as a definitive NO to your question to working with http and https on same port
Can we have both http and https listening on the same port?
Comment 1 Eric Covener 2011-11-22 14:36:45 UTC
No, and bugzilla is not for support or Q&A. Try the users mailing list.
https://issues.apache.org/bugzilla/show_bug.cgi?id=52228
You can try the mod_rewrite module but I suggest that you open another question on how to use it to make https redirects (you will still need to have multiple ports). I haven't worked with it so can't give you details about how to do it.
Like I said don't know much about the module so my guess is that you would need three ports. One non-SSL port for mod_rewrite to listen, one non-SSL for http traffic and one SSL port for https, you would have to make the 999 port for mod_rewrite and then have your services listen on two different port for http and https.
Pay attention to what Shane Madden said in his comment, http request on SSL enabled port would only give you errors even if you put mod_rewrite on that port.
Best Answer
If you have purchase a standard, single domain SSL certificate, then it will be for one domain, so you can only use it for domainname.com or www.domainname.com.
If you have purchased a wildcard or UCC certificate then it will allow either unlimited subdomains (in the case of a wildcard) or mulitple domains up to a certain number (in the case of UCC).