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:
The other answers here didn't work for me, but I found a pretty simple solution that did work.
I made the default one the last one listed, and I gave it ServerAlias *
.
For example:
NameVirtualHost *:80
ServerName www.secondwebsite.com
ServerAlias secondwebsite.com *.secondwebsite.com
DocumentRoot /home/secondwebsite/web
ServerName www.defaultwebsite.com
ServerAlias *
DocumentRoot /home/defaultwebsite/web
If the visitor didn't explicitly choose to go to something ending in secondwebsite.com
, they get the default website.