Restrict Direct IP Access To Website Without Affecting Other Sites

Solution 1:

One way would be to require that the client sends a Host header:

Require expr %{HTTP_HOST} .

Probably a better way is to define virtual hosts for all of the hostnames you want to support, but have the first virtual host, which is the default if none of the other ones match, deny connections:

<VirtualHost *>
  Require all denied
</VirtualHost>
<VirtualHost *>
  ServerName example.com
</VirtualHost>
<VirtualHost *>
  ServerName admin.example.com
</Virtualhost>
...