I will start with describing what I want to achieve.
First of all I have one main domain which is xxx.pl, a domain has 4 subdomains 000.xxx.pl, 111.xxx.pl, 222.xxx.pl, 333.xxx.pl. Also I have another domain yyy.pl with its own subdomains (mostly the same). Of course it will be more domains, but its not the point.
Now what I need is any domain which doesn't have its vhost set up for http, will point /var/www/pl.xxx and the same with https. (so its the default site) which for now I have set up as (and similar for https):
sites-enabled/999-default
<VirtualHost *:80>
ServerAdmin postmaster@xxx.pl
DocumentRoot /var/www/vhosts/pl.xxx
<Directory /var/www/vhosts/pl.xxx>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
So this file as far as I understand will be loaded as last so apache will go there if there was no more precise answer.
Then there is file for main domain (HTTP and HTTPS is the same except the keys etc.) which will be loaded before default site config.
sites-enabled/998-pl.xxx
<VirtualHost *:80>
ServerAdmin postmaster@xxx.pl
ServerName xxx.pl
ServerAlias *.xxx.pl
DocumentRoot /var/www/vhosts/pl.xxx
<Directory /var/www/vhosts/pl.xxx>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
And now I need to specify 2 domains (only on https), on http they should use sites-enabled/998-pl.xxx config.
sites-enabled/997-pl.xxx.000
ServerAdmin postmaster@xxx.pl
ServerName 000.xxx.pl
ServerAlias 000.xxx.pl
DocumentRoot /var/www/vhosts/pl.xxx.000
<Directory /var/www/vhosts/pl.xxx.000>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
And all would be good except the other domain yyy.pl on the https use the same config as the 000.xxx.pl address. And what I need it to restrict only 000.xxx.pl to use this address. Not all other not assigned domains.
so https://yyy.pl | https://000.yyy.pl etc. should use default-ssl settings instead of 000.xxx.pl settings.
Please help me understand whats going on. Maybe I misunderstood the apache config usage.
Edit:
Generally the problem is partially solved, because it works. but there is one interesting thing about dependency /etc/hosts entry with the subdomain configuration.