Disabling direct IP access prevents anyone from accessing your website using the IP address.
If anyone tries to access your site using the IP address then a 403 Forbidden error will be shown.
To disable direct IP access you would have to edit the virtual host file
sudo vi /etc/httpd/conf.d/example.com.conf
Modify the above command based on your domain name and location of virtual host file.
conf.d directory is the default location of the virtual host file which I used in one of my earlier tutorials about virtual host.
Paste the code given below in your virtual host file. Replace 184.108.40.206 with your server’s IP address
<VirtualHost *:80> ServerName 220.127.116.11 Redirect 403 / ErrorDocument 403 "No" DocumentRoot /dev/null/ UseCanonicalName Off UserDir disabled </VirtualHost>
After editing the virtual host file restart the server
sudo systemctl restart httpd