Nginx
set $stupid_spider "";
# If the request comes from one of these stupid spiders
if ($http_user_agent ~* (stupid|spider)) {
set $stupid_spider "1";
}
# And if it contains these weird characters
if ($uri ~ (\(|\)|\;|:|\+)) {
set $stupid_spider "${stupid_spider}1";
}
# Then we block it here
if ($stupid_spider = "11") {
return 404;
}
Apache
<LocationMatch "(\(|\)|\;|:|\+)">
SetEnvIfNoCase User-Agent "(stupid|spiders|-?)" GoAway=1
Deny from env=GoAway
</LocationMatch>