I know how to set up multiple hosts in an apache httpd.conf file but is it possible to make that dynamic.

If I put my folders in directories like this.


Can I write my httpd.conf file in a way like this

<VirtualHost *:80>

ServerName *.example.com
DocumentRoot "c:/development/Websites/%1/"


where %1or other variable marker is SiteA if the user visits sitea.example.com etc or event if siteA has to be a fully qualified domain that is fine.

2 Answers 2


Quite simply: no.

A DocumentRoot has to be a single directory on the server, and wildcards are not allowed.

You may be able to get the behaviour you're after by using RewriteRule statements mentioned in this answer, but YMMV.


At least in 2.4 you can:

<Macro virty $name>
<VirtualHost $name:80>

ServerName $name.example.com
DocumentRoot "c:/development/Websites/$name/"


Use virty SiteA
Use virty SiteB
Use virty SiteC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.