I only have Vhosts. Anything that hits the server by IP or using a hostname that is not currently active gets caught by the first entry in my vhosts.conf file which is "Junk".
That has a simple page which catches any page attempt and displays a simple page indicating that the site they are attempting is either offline or no longer supported. It provides the URI that was attempted and some simple contact info, Nothing else.
First entry in my vhosts.conf file is an unnamed (No ServerName or ServerAlias):
Code:
<VirtualHost *:80>
ServerAdmin "webmaster at domain.com"
DocumentRoot /www/vhosts/junk
ErrorLog logs/junk.errors
CustomLog logs/junk.combined combined
</VirtualHost>
The log files provide a good list of hack attempts since a lot of bots used IP based attempts.
Even if there is only 1 web page for the server, I still set it up this way.
Also, you can use a mod_rewrite to force access to your sites to be the hostname that you want it to be accessed by, keeping indexing consistent as well. This will help with search engine listings.
If you prefer everything be
http://www.hostname.tld then you can use something like:
Code:
RewriteCond %{HTTP_HOST} !^(.*)\.hostname\.tld$ [NC]
RewriteRule ^(.*)$ http://www.hostname.tld/$1 [R=301,L]You can do it the other way around too if you choose.