How to make undefined host go to default Page in apache2 virtual hosts
I am using named Virtual hosts
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/usr/local/apache2/docs/thegeekstuff"
ServerName test1.mydomain.com
ServerAlias www.test1.mydomain.com
ErrorLog "logs/thegeekstuff/error_log"
CustomLog "logs/thegeekstuff/access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/usr/local/apache2/docs/top5freeware"
ServerName test2.mydomain.com
ServerAlias www.test2.mydomain.com
ErrorLog "logs/top5freeware/error_log"
CustomLog "logs/top5freeware/access_log" common
</VirtualHost>
At the moment i have not defined www.mydomain.com
but when i open in browser it goes to my test1.mydomain.com
Is there any way that if i did not explicitly define that it redirect to either APache conf page
Also if i type ip address only then it also goes to that site.
I want that also to go to that undefiend page or something else
The site that gets served when no <VirtualHost>
matches for that NameVirtualHost
is the first one to load.
Just put a <VirtualHost>
block above your others with a bogus ServerName
, which serves the content that you want to be default.