Forum Moderators: coopster
Java/1.4.1_04
The code I'm using...
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if ($useragent=="Java/"){header("HTTP/1.0 403");die();}
?>
I'm using two = (==) to partially match the useragent. If it's Java then I want it blocked. I'm not going to try to block every specific version of Java/anything.
These bots using/posing/etc as Java come in various versions and so I simply want to block any useragents with "Java/" in the useragent.
- John
For your purpose, you can use any of a number of functions, e.g. strstr.
[pl.php.net...]
I use my .htaccess file to block these spiders:
#
# Deny bad behaving spiders
#
SetEnvIfNoCase User-Agent ^Java BadGuy
#
# Some files however can be accessed by the Bad Guys
#
SetEnvIf Request_URI "^(/error403\.php¦/robots\.txt)$" AllowBadGuy
#
# Ban the bad guys defined above, except for the files they are allowed to see
#
<Files *>
Order Deny,Allow
Deny from env=BadGuy
Allow from env=AllowBadGuy
</Files>
In my list of bad spiders I have:
SetEnvIfNoCase User-Agent ^NaverBot¦^TurnitinBot¦^ConveraCrawler¦^OmniExplorer_Bot¦^sohu¦^ichiro¦^Twiceler¦^voyager¦BecomeBot BadGuy
Change the broken pipe (¦) for a closed pipe character.
Regards,
Arjan
[edited by: jatar_k at 6:27 pm (utc) on July 2, 2006]
[edit reason] removed a couple bots to fix sidescroll [/edit]
A Close to perfect .htaccess ban list [webmasterworld.com]
and all it's following threads