Painless subdomains on your laptop
A lot of development we do nowadays like to reside on it’s own domain or subdomain (Drupal, Zend Framework apps, Wordpress, etc…). When we develop those on our own laptops, we tend to fill up our
/etc/hosts with fake subdomains pointing to
127.0.0.1, or constanly editing our
httpd.conf and redirect localhost’s
I had enough of that.
So I was thinking about setting up a wildcard domain that points everything to localhost. Then, I found out that one such already exists, courtesy of Sean Behan, who already set up hexxie.com like that.
So, just add the following little snippet to your apache.conf (you need to have the vhost_alias Apache module enabled):
<VirtualHost *:80> VirtualDocumentRoot /Users/kkovacs/Sites/%1 ServerName automated_domains ServerAlias *.hexxie.com </VirtualHost>
Restart Apache, and from then on you can reach subdirectories of your own DocumentRoot at every subdomain of
drupaltest.hexxie.com… You get it.
Of course this method can be very easily adapted to webservers other than apache.
Update: Now you can use xip.io for the same purposes, with even more flexibility, thanks to the 37signals team.