Create name based subdomain in apache2 conf.:
Some or many time we need to set the same document root for all or almost
each sub domains to a same document root, we can simply do it with apache virtual host setting as following.
For say if we want that all sub domains of example.com should be hosted on same server and share the same document root then we can use apache web server's ServerAlias Directive as follows
Open this file: /etc/apache2/sites-enabled/000-default.conf
and set this code:
<VirtualHost *:80>
ServerName example.com
ServerAlias server server2.domain.com server2
ServerAlias *.example.com
</VirtualHost>
Thanks
Some or many time we need to set the same document root for all or almost
each sub domains to a same document root, we can simply do it with apache virtual host setting as following.
For say if we want that all sub domains of example.com should be hosted on same server and share the same document root then we can use apache web server's ServerAlias Directive as follows
Open this file: /etc/apache2/sites-enabled/000-default.conf
and set this code:
<VirtualHost *:80>
ServerName example.com
ServerAlias server server2.domain.com server2
ServerAlias *.example.com
</VirtualHost>
Thanks