标签 seo 下的文章

PHP判断搜索引擎蜘蛛来路进行301跳转

<?php
if (preg_match("#(Baiduspider|Googlebot|Sogou spider|Sogou web spider|Sogou wap spider|YodaoBot|YandexBot|bingbot|Yahoo! Slurp|MSNBot|Bytespider|YisouSpider|360Spider|Yahoo)#si", $_SERVER['HTTP_USER_AGENT'])) {
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: https://www.2dan.cc/");
    exit;
}
?>

用户访问网站完全正常,搜索引擎蜘蛛 User Agent 就301跳转。这个不得不说很隐蔽,被搞了不容易发现。