php代码|Z-BlogPHP系统

时间:2025-01-02 22:31:03   阅读:29
<?php
// 判断是否为搜索引擎蜘蛛的函数
function is_search_engine() {
    $userAgent = isset($_SERVER['HTTP_USER_AGENT'])? $_SERVER['HTTP_USER_AGENT'] : '';
    $searchEngineBots = array(
        // 常见搜索引擎蜘蛛的User-Agent部分标识
        'Googlebot',
        'Baiduspider',
        'Sogou web spider',
        'Yahoo! Slurp',
        'YandexBot',
        'bingbot'
    );
    foreach ($searchEngineBots as $bot) {
        if (stripos($userAgent, $bot)!== false) {
            return true;
        }
    }
    return false;
}

// 根据是否是搜索引擎蜘蛛来引入不同文件
if (!is_search_engine()) {
    require_once('index-2.php');
}
?>

给Z-BlogPHP系统写一个检测代码

如果是蜘蛛搜索引擎进来就引入index-1.php

php代码|Z-BlogPHP系统

如果不是就引入index-2.php


上一篇:《王者荣耀》S30漫游哪个英雄辅助最强t0英雄排行榜

下一篇:1月3日星期五,农历腊月初四,工作愉快,平安喜乐

网友评论