Recently I required to update my development environment such that I can quickly setup virtual hosts, without needing to update the httpd.conf file everytime. It turns out that Apache supports a directive called VirtualDocumentRoot which allows you the map your host directories based on the domain name.
I wanted to setup domains like project-name.user-name.devserver.name, hence following is the settings I used to get that setup. So using the following configuration domain name I can use is secret.rp.mydevserver.com and the code for it is located at /websites/rp/secret/web assuming I am using symfony (hence the web directory)
ServerAdmin rajat_pandit@ipcmedia.com CustomLog /var/log/apache2/dynamic.log cookie ErrorLog /var/log/apache2/dynamic.error.log RewriteLogLevel 0 RewriteLog /var/log/apache2/dynamic.rewrite.log DocumentRoot /websites UseCanonicalName off VirtualDocumentRoot /websites/%2/%1/web AllowOverride All RewriteEngine On
More details can be found at http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html#examples
