How To Create A Blank Root For Apache Virtual Host?

If you don’t want Apache to serve the first Virtual Host when you get a request for the server IP. (because that is what is supposed to happen).

If someone or somebot is attempting to see what is at the ip address, you can serve a blank page instead as follows:

vi /etc/apache2/sites-available/000-default.conf

Insert this VirtualHost at the top of the list/page.

VirtualHost *:80
       ServerName server-ip
        ServerAlias server-ip
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined
        DocumentRoot /var/www/html

mkdir /var/www/html

create a blank index.html in the directory

chmod 644 index.html

create .htaccess as well

IfModule mod_rewrite.c
     RewriteEngine On     
     Options -Indexes

chmod 440 .htaccess

systemctl restart apache2

You may also like...