冰豆网

分享网络精彩
bingdou.com.cn

Nginx网站如何屏蔽电脑端,屏蔽蜘蛛,屏蔽微信,QQ等

时间:2024-07-28加入收藏

将下方代码直接放置在网站伪静态规则里即可:

if ($http_user_agent ~* "windows") { return 444; } #屏蔽电脑端
if ($http_user_agent ~* "MicroMessenger") { return 444; } #屏蔽微信
if ($http_user_agent ~* "QQ/") { return 444; } #屏蔽QQ内
   
if ($http_referer ~* "baidu.com|sogou.com|so.com|google.com|bing.com|sm.cn") { return 444; } 
if ($http_user_agent ~* "SemrushBot|python|AhrefsBot|hubspot|opensiteexplorer|leiki|webmeup|Baiduspider|baiduspider|sogou spider|sogou web|360spider|Bytespider|toutiao|Sosospider|YodaoBot|msnbot|Googlebot|Amazonbot|dataforseo|DataForSeoBot|semrush|babbar|mj12bot|116.0.0.0") { 
return 444; } #屏蔽各大搜索引擎

打 赏
打赏二维码

TGA: 技巧

分享到:


官方微信二维码冰豆网官方微信公众号