简体   繁体   中英

Default virtualhost overriding wildcard subdomain virtual host

I'm trying to create wildcard domains where

-I have the root server (landing page) on https://example.com

-And all subdomains (completely dynamic) on https://*.example.com

This is the wildcard virtualhost (listed BELOW the SSL include, which contains the root domain):

<VirtualHost *:443>
    ServerName test.example.com
    ServerAlias *.example.com:443

    DocumentRoot /opt/lampp/htdocs/production/

    SSLEngine on
    SSLCertificateFile /etc/cert.pem
    SSLCertificateKeyFile /etc/privkey.pem
    SSLCertificateChainFile /etc/chain.pem
</VirtualHost>

This works fine for test.example.com, but when I try going on anything else, for instance 123.example.com it will default to the first virtualhost, defined in httpd-ssl, not this one.

So my question is, seeing that whichever ServerName I have set in the virtualhost, works, the rest do not, how can I have subdomains override the default virtualhost? Without ServerName it always defaults to the root (only ServerAlias).

I have tried placing this code BEFORE (inside the httpd-ssl) default host, but then it always used this for root.

Thanks!

I have fixed it by placing this snippet above default and removing ServerName. The issue was that I had ServerName in the root www., but I'm not using www.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM