Dynamische vHosts mit apache2 Webserver (Wildcard)

Modul „vhost_alias“ aktivieren

–> vhost_alias.load
/etc/apache2/mods-enabled
/etc/apache2/mods-available

apache2ctl -M

nach vhost_alias.load suchen und wenn nicht aktiviert mit a2enmod aktivieren

sudo a2enmod vhost_alias

danach neu starten

service apache2 restart

dynamischen vHost konfigurieren

<VirtualHost *:80>
    	ServerAlias *.example.com
    	VirtualDocumentRoot /var/www/example.com/subdomain/%1/public/
	ServerAdmin mail@example.com
	<Directory /var/www/example.com/subdomain/*/>
		Options -Indexes +FollowSymLinks +MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>
  ErrorLog ${APACHE_LOG_DIR}/error.log
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
</VirtualHost>

Source:

https://httpd.apache.org/docs/2.4/mod/mod_vhost_alias.html

https://www.chris-shaw.com/blog/using-wildcards-in-virtual-hosts-on-apache