在nginx的server字段中配置下面内容即可
if ($http_user_agent ~* (baiduspider|googlebot|bing|sogou|yahoo)){ return 503; }
|-------|----------------------------------------------------------------------------------------| | 1 2 3 | if ($http_user_agent ~* (baiduspider|googlebot|bing|sogou|yahoo)){ return 503; } |
如果单独屏蔽百度蜘蛛就是
if ($http_user_agent ~* baiduspider){ return 503; }
|-------|-------------------------------------------------------| | 1 2 3 | if ($http_user_agent ~* baiduspider){ return 503; } |