I'm trying to figure out the configuration for the following:

Multiple Domains - (example1.com, example2.com, example3.com) Single Virtual Host Wildcard Subdomains (*.example1.com, *example2.com, etc)

My current configuration is:

<VirtualHost *:80>
     ServerAlias *.|DOMAIN|
     RewriteEngine on
     ReWriteCond %{SERVER_PORT} !^443$
     RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

<VirtualHost *:443>
     ServerAlias *.|DOMAIN|
     SSLEngine On
     DocumentRoot /SITES/WWW/public
     SSLCertificateFile /SITES/SSL/example1.com.crt
     SSLCertificateKeyFile /SITES/SSL/example1.com.key
     SSLCertificateChainFile /SITES/SSL/gd_bundle-g2-g1.crt

My VirtualHosts and redirects are working fine for all domains. The issue I'm having is with SSL. Each domain has its own SSL certificate and I can't seem to use the |DOMAIN| variable in the SSL configuration.

How do I go about configuring the SSL certificate based on the domain being used?

Thank you in advance for any guidance - really appreciate it!


Try install vhost with this utility https://github.com/syntaxweaver/Ubuntu-ServConf then you can duplicate vhost directory to other domain. It will save your time to setup web server.

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.