Dynamic Virtual Hosts In Apache

Solution 1:

I suggest you have a look at the Apache website for dynamic virtual hosts. The other methods require a restart of the Apache server.

http://httpd.apache.org/docs/2.0/vhosts/mass.html

Solution 2:

I figured out how to do it after reading Dark Ninja's answer. Here's what my httpd-vhosts.conf file looks like now.

# Dynamic virtual hosts.
# See http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html
UseCanonicalName Off
VirtualDocumentRoot /www/%0/htdocs/

I also had to enable mod_vhost_alias by uncommenting this line in httpd.conf

LoadModule vhost_alias_module modules/mod_vhost_alias.so