Allow access to domain name with Apache only
I have a bunch of scripts on a server running Ubuntu 12.04 and Apache. Currently I can access the site in both directions: via IP and domain name, for example: http://example.com
and http://1.1.1.1
, where example.com has an A record pointing to 1.1.1.1
. My question is, is there a way to throw a 403 or similar error when the site is accessed by the server's IP address and not by its domain name?
All I could find about my question is a link to Apache HOW-TOs , however there is no information on how to achieve this whatsoever. My guess is that I need to edit the default config file, but I don't know what exactly to change. Or maybe there is a module for this?
source to share