5 December 2014
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
  1. LoadModule vhost_alias_module modules/mod_vhost_alias.so
  2.  
  3. <VirtualHost *:80>
  4. ServerAdmin info@browse-tutorials.com
  5. ServerName .localhost
  6. ServerAlias *.localhost
  7.  
  8. VirtualDocumentRoot /var/www/%-2+
  9. Options -Indexes +FollowSymLinks
  10.  
  11. <Directory /var/www/*>
  12. Options Indexes FollowSymLinks
  13. Allow from all
  14. AllowOverride All
  15. Order Allow,Deny
  16. Require all granted
  17. </Directory>
  18.  
  19. ErrorLog /var/log/httpd/.localhost-error_log
  20. CustomLog /var/log/httpd/.localhost-access-log combined
  21. </VirtualHost>
Programming Language: Apache configuration