如何有效应对百度统计中的恶意刷量及问题?

摘要:做站的每年总会遇到各种各样的攻击,比如统计被恶意刷关键字刷量的事情,大多是那些做灰产刷广告或诈骗的人。 今天来分享一招解决百度统计被刷的事,这种通常是通过访问你网站URL+参数的方式,例如: https:www.xxx
做站的每年总会遇到各种各样的攻击,比如统计被恶意刷关键字刷量的事情,大多是那些做灰产刷广告或诈骗的人。 今天来分享一招解决百度统计被刷的事,这种通常是通过访问你网站URL+参数的方式,例如: https://www.xxx.com/index.html?ad=3.nuoya%E8%93% 那么我们只需要配置网站的 URL重写(Rewrite)规则,拦截拒绝这类的访问请求即可。 常规网站程序都配置有 web.config 文件,可以将拦截规则写在这里;或是在 web_config/rewrite.config 里写的,二者按个人情况选其一即可。 web.config 的写法如下(在 rewrite 内增加 rules): <?xml version="1.0" encoding="UTF-8"?> <configuration> <location path="." allowOverride="false" inheritInChildApplications="false"> <system.webServer> <rewrite> <rules> <!-- 拦截所有包含 ad= 的查询参数的请求 --> <rule name="Block malicious ad parameter" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{QUERY_STRING}" pattern="ad=" /> </conditions> <action type="CustomResponse" statusCode="403" subStatusCode="0" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> </rules> </rewrite> <!-- 以下是你原有的外部配置文件引用,保持不变即可 --> <defaultDocument configSource="web_config\default.config" /> <httpErrors configSource="web_config\httpErrors.config" /> <handlers configSource="web_config\php.config" /> </system.webServer> </location> </configuration> web_config/rewrite.config 的写法如下(增加 rule 标签段): <!-- ===== 新增规则:拦截包含恶意参数 ad= 的请求 ===== --> <rule name="Block_Malicious_Ad_Parameter" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{QUERY_STRING}" pattern="ad=" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Access Denied" /> </rule> 如果想拦截多个参数的,可以在<conditions>标签内再增加,如: <add input="{QUERY_STRING}" pattern="click=" /> <add input="{QUERY_STRING}" pattern="from=" /> 最后,保存配置后,重启服务器即可生效,这时发现百度统计已恢复正常,并且这种带“?ad=”的参数访问直接被拦截访问了,同时也是减轻服务器的带宽消耗。