Setting default virtual host on apache

47 views Asked by At

I have set my local development machine to use apache to serve virtual hosts based on folders using the following setup in apache.

<VirtualHost *:80>
    ServerName dev
    DocumentRoot /Users/ben/Sites
    VirtualDocumentRoot /Users/ben/Sites/%-2/htdocs
    UseCanonicalName Off

    <Directory "/Users/ben/Sites/*/htdocs">
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
    </Directory>

</VirtualHost>

Is it possible to set a default so that when the server is accessed externally it chooses a particular one of those folders?

Thanks in advance

1

There are 1 answers

0
covener On BEST ANSWER

The most straightforward way is to add a *:80 virtualhost after this one that doesn't use VirtualDocumentRoot at all and has a specific DocumentRoot. It will be matched only when the ServerName/ServerAlias matches the hostname used by your external clients.