How do you set the default website to serve when your IP address is entered as URL?

I have a server with multiple websites hosted and distinguishable using name-based virtual hosting of apache.

How do I set it so that a specific website is hosted when the ip of my server is entered in the address bar?


Solution 1:

What you want to use is the _default_ VirtualHost.

<VirtualHost _default_:80>
    DocumentRoot /www/default80
    # ...
</VirtualHost>

It's described here. Basically if nothing else match the request the _default_ host will be used.

EDIT
This could also be written as:

<VirtualHost *>
    DocumentRoot /www/default
    # ...
</VirtualHost>

Is is important that this is the first VirtualHost in the configuration since Apache will start matching them from top to bottom, selecting the one that fit the best based on ServerName and ServerAlias.

This post might also be of interest: Apache default VirtualHost

Solution 2:

just find the Include sites-enabled/ line in your apache2.conf file and add the path to the conf file you want to be site default above it. from:

Include sites-enabled/

to

Include sites-enabled/mydefault.conf
Include sites-enabled/