how can I set a default VirtualHost in apache? Preferably, I want the default host not to be the same as the ip address host. Now I have something like this:
NameVirtualHost *
<VirtualHost *>
ServerAdmin [email protected]
DocumentRoot /someOtherDir/
ServerAlias ip.of.the.server
</VirtualHost>
<VirtualHost *>
ServerAdmin [email protected]
DocumentRoot /someroot/
ServerAlias domain.com *.domain.com
</VirtualHost *>
If a domain is forwarded to my server, but isn't in this vhost.conf file, the files from /someOtherDir/ are loaded, as expected. But I want to be able to use a different root for the ip-address itself and domains which aren't added to the vhost.conf file (yet). Is this possible?
edit: corrected my code a bit, so it looks more like the actual vhost.conf file
I found the answer: I remembered that Apache uses the first block if no other matching block is found, so I've added a block without a serveralias
at the top of the blocks:
NameVirtualHost *
<VirtualHost *>
DocumentRoot /defaultdir/
</VirtualHost>
<VirtualHost *>
ServerAdmin [email protected]
DocumentRoot /someOtherDir/
ServerAlias ip.of.the.server
</VirtualHost>
<VirtualHost *>
ServerAdmin [email protected]
DocumentRoot /someroot/
ServerAlias domain.com *.domain.com
</VirtualHost>