To add a wildcard domain (i.e. *.subdomain.mydomain.domain) all you really need to do is set up a new vhost in the Apache config and use the matching ServerName and ServerAlias:
ServerName subdomain.mydomain.domain
ServerAlias *.subdomain.mydomain.domain
That’s it, you can easily utilize and parse all subdomains below subdomain.mydomain.domain now.