Forum Moderators: phranque
I do it all the time.
Grab the script I have posted in this post:
[webmasterworld.com...]
The bad IP script that writes to an .htaccess file. Mod the code just a bit, so it looks at UA instead of IP, and instead of pointing to an .htaccess file, point it to a "bad_ua.txt" file. Fill that file up with all the bad UA's, and you are good to go!
Note that you will not need the trap.pl file to write to the file bad_ua.txt...
dave
That code looks to be usable as-is, but I didn't research it or test it... That's your job. :)
A general recommendation for code posted here or on any forum: If you don't understand it thoroughly, then look up each directive [httpd.apache.org] and do a "sanity check" on the syntax and the value of the variables in the posted code. This will also expand your knowledge of Apache directives over time, so you don't have to wonder if the code's any good when you see it.
.htaccess, like http.conf, and conf.d are server configuration files. You should fully understand the operation and effect of any code you add to any of those files.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim