WordPress自带的搜索非常耗资源,打开网站日志发现,发现很来自国外的垃圾营销蜘蛛SemrushBot的搜索,在宝塔防火墙中屏蔽IP也无效,网上找了一下,现成的代码:
#禁止垃圾蜘蛛抓取
if ($http_user_agent ~* (SemrushBot|python|Linespider|crawler|DingTalkBot|simplecrawler|ZoominfoBot|zoombot|Neevabot|coccocbot|Facebot|YandexBot|Adsbot|DotBot|Applebot|DataForSeoBot|MJ12bot|BLEXBot|trendictionbot0|trendictionbot|AhrefsBot|hubspot|opensiteexplorer|leiki|webmeup)) { return 444;}
以宝塔为例,将上代码加到站点配置文件,最后一个”}“前面,当这些垃圾蜘蛛访问网站,只能得到444 没有任何数据。
再加个当链接中包含/search/重定向到其它页面。
代码添加到主题函数模板中:
请登录后发表评论
注册
请登录后查看评论内容