$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if(stripos($ua,'spider') !== false){
echo '正常页面';
}else{
echo '菠菜页面';
} nginx的 # set $flag 0;
# if ($http_user_agent ~* "360Spider|Baiduspider|Baiduspider-render|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Bingbot|MSNBot|YisouSpider|Sosospider|Sogou spider|Sogou web spider|Bytespider"){
# set $flag "${flag}1";
# }
# if ($http_user_agent !~* "mobile|nokia|sony|ericsson|mot|samsung|htc|sgh|lg|sharp|sie-|philips|panasonic|alcatel|lenovo|iphone|ipod|blackberry|meizu|android|netfront|symbian|ucweb|windowsce|palm|operamini|operamobi|openwave|nexusone|cldc|midp|wap") {
# set $flag "${flag}2";
# }
# if ($flag = "01") {
# #return 503;
# }
# if ($flag = "02") {
# return 503;
# }
把# 去掉
页:
[1]