Centos – In Apache, how to disable access to a website when someone only uses the IP address in a web browser

apache-2.2centos

I'm using apache web server on CentOS and I need to disable the ability for people to access the website by using the server's IP address in a web browser. I want it so that when someone attempts to browse to the IP address they get a forbidden error message.

What configurations would be necessary to do that?

Best Answer

Just set up the default virtual host. There is a commented example in httpd.conf or do something trivial like:

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www/html
</VirtualHost>