1

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

1 Answer 1

3

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.

2
  • so u mean first i need to have default index.html at location like /var/www/default/index.html then in serverbname i use www.blabla.com then evrything will go there Jul 5, 2013 at 8:10
  • 1
    @user1513613 Right, you will create a separate <VirtualHost> block that will be used as the default for catching requests to domains that aren't covered by a different one. Jul 5, 2013 at 9:14

You must log in to answer this question.

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