Dynamic Virtual Hosts In Apache

apache-2.2virtualhost

My httpd-vhosts.conf file looks like this:

<VirtualHost *:80>
DocumentRoot "/www/foo/htdocs"
ServerName foo
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/www/bar/htdocs"
ServerName bar
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/www/baz/htdocs"
ServerName baz
</VirtualHost>

Notice the pattern? Is there any way to cut down on the duplication, or am I stuck with having a separate VirtualHost entry for each site?

Best Answer

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

Related Topic