views:

20

answers:

1

Hi,

Lets' asume I have 1 domain on a Ubuntu Server in the following directory:

/var/www/domain1.com/httpdocs

and that the ip address is 100.100.100.100

If I go to www.domain1.com, Apache will server the files inside the httpdocs folder.

How can I avoid that if the following file exists:

/var/www/domain1.com/privatefile.html

.. apache shows it by going to:

http://100.100.100.100/domain1.com/privatefile.html

In other words, I want to display the content in the httpdocs only, no by ip address.

A: 

In a vhost setup, Apache will use the first vhost defined as the default one to serve when a request comes in by IP. So just make a "dummy" vhost that points nowhere, and make sure it's the first one in the config file:

<VirtualHost *:80>
    ServerName nothing.nowhere
    ServerAdmin [email protected]
    DocumentRoot /var/empty
    <Directory /var/empty>
        Order Allow,Deny
    </Directory>
</VirtualHost>
Alex Howansky
Thanks Alex. very helpful.
fast-dev