So I have been reading up on analytics spam and have been looking for a way of dealing with it across multiple wordpress sites I run. The best solution seems to be to block the hostname via my htaccess file. The issue is I would need to set this up manually across all sites, making initial setup time-consuming and ongoing maintenance a nightmare!
My question is this: can I include this information within a plugin or theme file - i.e. create a plugin that alters the htaccess file to filter out from a master list of hostnames?