Sorry if this has been asked before, but I've been researching for hours now with no real definitive answer.
I am working on a site that has had some serious security flaws in the past. These have been fixed (and I am constantly checking to make sure there aren't others), but the site is getting hammered by bots. I've implemented some checks in PHP using a 3rd party to ban known spam IP addresses and I have blocked referrer such as semalt in .htaccess, which has helped massively, but it's not enough.
Because the problem is so bad and it takes me so long (hours per day) to manually block IPs, host names, etc, I wanted to take a more aggressive approach. Rather than blocking specific details, I'd rather just let through what I want using htaccess: - Good bots like Google, MSN, Yahoo, etc. - Anyone with a hostname.
I realise this will still let some bad bots through, but the majority of traffic comes from bots without a hostname, so it will be a good start.
I have two questions:
1) Is there a better way to approach this?
2) If not, how do I achieve this?
This is what I have so far (I have a bigger list of browsers), but it does not seem to work:
#allow just search engines we like, we're OPT-IN only
#a catch-all for Google
BrowserMatchNoCase Google good_pass
BrowserMatchNoCase Slurp good_pass
BrowserMatchNoCase ^Yahoo good_pass
BrowserMatchNoCase ^msnbot good_pass
BrowserMatchNoCase SandCrawler good_pass
BrowserMatchNoCase Teoma good_pass
BrowserMatchNoCase Jeeves good_pass
#allow Firefox, MSIE, Opera etc., will punt Lynx, cell phones and PDAs, don't care
BrowserMatchNoCase Chrome good_pass
BrowserMatchNoCase Mozilla good_pass
#Let just the good guys in, punt everyone else to the curb
#which includes blank user agents as well
Order Deny, Allow
Deny from all
Allow from env=good_pass