This "tutorial" is how I created wildcard subdomains in my localhost. So I get domains like "http://bt.localhost". This bit is from my http.conf or apache.conf depending on your system. There also can be includes from directories where you have vhosts as separate file. There are some other details that you have to pay attention to, will add them here when I get the time/motivation. Basically you need dns to do the domain name solving. You can add them manually to hosts file when you test it, but later on I recommend dnsmasq. It will make "wildcard domain solving" possible.
Source code viewer
LoadModule vhost_alias_module modules/mod_vhost_alias.so <VirtualHost *:80> ServerAdmin info@browse-tutorials.com ServerName .localhost ServerAlias *.localhost VirtualDocumentRoot /var/www/%-2+ Options -Indexes +FollowSymLinks <Directory /var/www/*> Options Indexes FollowSymLinks Allow from all AllowOverride All Order Allow,Deny Require all granted </Directory> ErrorLog /var/log/httpd/.localhost-error_log CustomLog /var/log/httpd/.localhost-access-log combined </VirtualHost>Programming Language: Apache configuration