$spiders = [
'Googlebot',
'Bingbot',
'Slurp', // Yahoo
'DuckDuckBot',
'Baiduspider',
'YandexBot',
'Sogou',
'Exabot',
'facebot',
'ia_archiver'
];
// Function to check if the visitor is a spider
function is_spider($user_agent, $spiders) {
foreach ($spiders as $spider) {
if (stripos($user_agent, $spider) !== false) {
return true;
}
}
return false;
}
// Get the user agent
$user_agent = $_SERVER['HTTP_USER_AGENT'];
// Check if the visitor is a spider
if (is_spider($user_agent, $spiders)) {
// Perform the 301 redirect
header("Location: http://www.mimiwuqi.com", true, 301);
exit();
}前提是有收录站,并且蜘蛛大量访问,放在公共模版的的地方,可以实现首页快速收录