我的托管帐户中的某些网站上存在EXTREME机器人问题。僵尸程序占用了我整个托管帐户超过98%的CPU资源和99%的带宽。这些漫游器每小时为我的网站产生超过1 GB的流量。所有这些站点的实际人流量都不超过100 MB /月。
我已经对robots.txt和.htaccess文件进行了广泛的研究,以阻止这些bot,但是所有方法均失败了。
我也将代码放在robots.txt文件中,以阻止对脚本目录的访问,但是这些漫游器(Google,MS Bing和Yahoo)会忽略规则并始终运行脚本。
我不想完全阻止Google,MS Bing和Yahoo僵尸程序,但我想限制那里的爬网率。另外,在robots.txt文件中添加抓取延迟语句不会降低机器人的速度。下面列出了我当前用于所有网站的robots.txt和.htacces代码。
我已经设置了Microsoft和Google网站管理员工具,以将抓取速度降低到绝对最小值,但是它们仍然以10次点击/秒的速度访问这些网站。
此外,每次我上载导致错误的文件时,整个VPS网络服务器都将在几秒钟内关闭,以至于由于这些bot的点击量激增,我什至无法访问该网站纠正此问题。
我该怎么做才能阻止网站流量的出现?
在过去的几个月中,我多次尝试向我的网络托管公司(site5.com)询问此问题,他们无法帮助我解决此问题。
我真正需要的是阻止Bots运行rss2html.php脚本。我尝试了会话和Cookie,但都失败了。
robots.txt
User-agent: Mediapartners-Google
Disallow:
User-agent: Googlebot
Disallow:
User-agent: Adsbot-Google
Disallow:
User-agent: Googlebot-Image
Disallow:
User-agent: Googlebot-Mobile
Disallow:
User-agent: MSNBot
Disallow:
User-agent: bingbot
Disallow:
User-agent: Slurp
Disallow:
User-Agent: Yahoo! Slurp
Disallow:
# Directories
User-agent: *
Disallow: /
Disallow: /cgi-bin/
Disallow: /ads/
Disallow: /assets/
Disallow: /cgi-bin/
Disallow: /phone/
Disallow: /scripts/
# Files
Disallow: /ads/random_ads.php
Disallow: /scripts/rss2html.php
Disallow: /scripts/search_terms.php
Disallow: /scripts/template.html
Disallow: /scripts/template_mobile.html
.htaccess
ErrorDocument 400 http://english-1329329990.spampoison.com
ErrorDocument 401 http://english-1329329990.spampoison.com
ErrorDocument 403 http://english-1329329990.spampoison.com
ErrorDocument 404 /index.php
SetEnvIfNoCase User-Agent "^Yandex*" bad_bot
SetEnvIfNoCase User-Agent "^baidu*" bad_bot
Order Deny,Allow
Deny from env=bad_bot
RewriteEngine on
RewriteCond %{HTTP_user_agent} bot\* [OR]
RewriteCond %{HTTP_user_agent} \*bot
RewriteRule ^.*$ http://english-1329329990.spampoison.com [R,L]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
# Don't show directory listings for directories that do not contain an index file (index.php, default.asp etc.)
Options -Indexes
<Files http://english-1329329990.spampoison.com>
order allow,deny
allow from all
</Files>
deny from 108.
deny from 123.
deny from 180.
deny from 100.43.83.132
更新以显示附加的用户代理BOT检查代码
<?php
function botcheck(){
$spiders = array(
array('AdsBot-Google','google.com'),
array('Googlebot','google.com'),
array('Googlebot-Image','google.com'),
array('Googlebot-Mobile','google.com'),
array('Mediapartners','google.com'),
array('Mediapartners-Google','google.com'),
array('msnbot','search.msn.com'),
array('bingbot','bing.com'),
array('Slurp','help.yahoo.com'),
array('Yahoo! Slurp','help.yahoo.com')
);
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
foreach($spiders as $bot) {
if(preg_match("/$bot[0]/i",$useragent)){
$ipaddress = $_SERVER['REMOTE_ADDR'];
$hostname = gethostbyaddr($ipaddress);
$iphostname = gethostbyname($hostname);
if (preg_match("/$bot[1]/i",$hostname) && $ipaddress == $iphostname){return true;}
}
}
}
if(botcheck() == false) {
// User Login - Read Cookie values
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$radio_1 = $_COOKIE['radio_1'];
$radio_2 = $_COOKIE['radio_2'];
if (($username == 'm3s36G6S9v' && $password == 'S4er5h8QN2') || ($radio_1 == '2' && $radio_2 == '5')) {
} else {
$selected_username = $_POST['username'];
$selected_password = $_POST['password'];
$selected_radio_1 = $_POST['group1'];
$selected_radio_2 = $_POST['group2'];
if (($selected_username == 'm3s36G6S9v' && $selected_password == 'S4er5h8QN2') || ($selected_radio_1 == '2' && $selected_radio_2 == '5')) {
setcookie("username", $selected_username, time()+3600, "/");
setcookie("password", $selected_password, time()+3600, "/");
setcookie("radio_1", $selected_radio_1, time()+3600, "/");
setcookie("radio_2", $selected_radio_2, time()+3600, "/");
} else {
header("Location: login.html");
}
}
}
?>
我还在rss2html.php脚本的顶部添加了以下内容
// Checks to see if this script was called by the main site pages, (i.e. index.php or mobile.php) and if not, then sends to main page
session_start();
if(isset($_SESSION['views'])){$_SESSION['views'] = $_SESSION['views']+ 1;} else {$_SESSION['views'] = 1;}
if($_SESSION['views'] > 1) {header("Location: http://website.com/index.php");}
rss2html.php
您的网站如何使用?通过PHP包含,重定向,Ajax ....?
file_get_contents
...?似乎很奇怪。该文件在另一台服务器上还是什么?
robots.txt
?机械手读取更新的版本可能需要一些时间。