2

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 %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

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.

0

At least in 2.4 you can:

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

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

</VirtualHost>
</Macro>

Use virty SiteA
Use virty SiteB
Use virty SiteC

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .