All HowTo's Web Servers

Block Access to Apache by IP Requests

Sometimes a visitor will arrive at your webserver by specifying the target (your server) by IP address only. This means they will get the first default vhost. It also means they will get an SSL error (mismatching name). This article shows how you can block that with a 403.

Put the following into your vhosts. If you know your primary (default) vhost, you can simply place it there. Or in a “.htaccess” file.

Replace the IP address “” with your servers actual public IP address.

RewriteEngine On
RewriteCond %{HTTP_HOST}
RewriteRule .* - [F]


Leave a Reply

Your email address will not be published. Required fields are marked *