# Use name-based virtual hosting.
NameVirtualHost *:80
UseCanonicalName Off
# ~/Sites/ vhost configuration - sends foo.bar.dev to ~/Sites/bar/foo
<VirtualHost *:80>
VirtualDocumentRoot /Users/dave/Sites/%2/%1
<Directory "/Users/dave/Sites">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
What that VirtualDocumentRoot does is map the above company and project to the %2 and %1 variables, respectively. So whenever I surf to
http://foo.bar.dev
, I end up in~/Sites/bar/foo
.
Dave’s a clever man.
Zero-config development with Apache’s VirtualDocumentRoot and xip.io →