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.
c:\
development\
websites\
SiteA
SiteB
SiteC
Can I write my httpd.conf file in a way like this
<VirtualHost *:80>
ServerName *.example.com
DocumentRoot "c:/development/Websites/%1/"
</VirtualHost>
where %1
or 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.
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: