Blocking UserAgent libwww-perl with .htaccess not working

.htaccessapache-2.2useragent

The server is running on Apache, and trying to block libwww-perl, but not sure why it's not working. I've put the following in my .htaccess, but when I run the test I still get the notification that libwww-perl is still not blocked.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} libwww-perl.* 
RewriteRule .* – [F,L]

I viewed the post here How to create .htaccess and block UserAgent libwww-perl?

But it seems they are running IIS7 so I don't think the answers there apply.

I've tried adding:

SetEnvIfNoCase User-Agent "^Wget" bad_bot 
SetEnvIfNoCase User-Agent "^EmailSiphon" bad_bot 
SetEnvIfNoCase User-Agent "^EmailWolf" bad_bot 
SetEnvIfNoCase User-Agent "^libwww-perl" bad_bot

<Location /> 
Order allow,deny 
Allow from all 
Deny from env=bad_bot 
</Location>

Which was suggested in another article http://community.spiceworks.com/how_to/1443-how-to-block-libwww-perl, but that gives me an internal server error 500

Any ideas?

Kind Regards

Best Answer

Try the block below, I just tested it myself on one of my Apache setups and it worked fine.

<IfModule mod_rewrite.c>   
RewriteEngine on

SetEnvIfNoCase User-Agent ^libwww-perl bad_bot

Order Allow,Deny  
Allow from ALL   
Deny from env=bad_bot