0

default.conf

<VirtualHost *:80>
    DocumentRoot /var/www/example
    ServerName example.com
    DirectoryIndex index.php index.html
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/subdomain
    ServerName subdomain.example.com
    DirectoryIndex index.php index.html
</VirtualHost>

default-ssl.conf

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        DocumentRoot /var/www/example/public
        SSLEngine on
        SSLCertificateFile      /var/www/Origin.crt
        SSLCertificateKeyFile   /var/www/Key.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                        SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                        SSLOptions +StdEnvVars
        </Directory>

        # BrowserMatch "MSIE [2-6]" \
        #               nokeepalive ssl-unclean-shutdown \
        #               downgrade-1.0 force-response-1.0
    </VirtualHost>

    <VirtualHost *:443>
        DocumentRoot /var/www/subdomain/public
        SSLEngine on
        SSLCertificateFile      /var/www/Origin.crt
        SSLCertificateKeyFile   /var/www/Key.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                        SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                        SSLOptions +StdEnvVars
        </Directory>

        # BrowserMatch "MSIE [2-6]" \
        #               nokeepalive ssl-unclean-shutdown \
        #               downgrade-1.0 force-response-1.0
    </VirtualHost>
</IfModule>

If I delete the main site, it loads the subdomain perfectly. If the main site is enabled the subdomains loads the main site. By load I mean it doesn't redirect, it just loads the main site directory.

1 Answers1

0

The <VirtualHost *:80> are independent from <VirtualHost *:443> and doesn't inherit any configuration from each other. Both your HTTPS virtualhosts are missing the ServerName directive; the first match gets shown as the default website.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122