A colleague (thanks Danny) pointed me to this solution to host multiple development environments under a single sub-domain name.

Step 1. Configure a type A domain record by using a wildcard and a fixed sub-domain name like:

*.lab    A    127.0.0.1

( why didn’t I think of that x_X )

Step 2. Enable mod_vhost_alias in Apache if not already active.

Step 3. Configure a virtual host and use the wildcards from mod_vhost_alias to your liking, for example

<VirtualHost 127.0.0.1:80>
    ServerName lab.yourdomain.com
    VirtualDocumentRoot /var/my_flexible_friends/%1
</VirtualHost>

would redirect myproject.lab.yourdomain.com to 127.0.0.1 and serve pages from /var/my_flexible_friends/myproject but would also redirect jquery.lab.yourdomain.com to 127.0.0.1 and serve pages from /var/my_flexible_friends/jquery.

Just look at the mod_vhost_alias documentation for more possibilities.
Also a nice consistent setup to share in development teams.

If you happen to stumble upon apache error messages like ‘Request exceeded the limit of 10 internal redirects due to probable configuration error.’, just change your .htaccess file by added the rule RewriteBase /. This will most likely happen when you are using the windows hosts file instead of a real domain.

See also Stackoverflow Infinite Rewrite Loop

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteBase /
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]