Puock 主题 go.php 无法被搜索引擎抓取的问题解决方案

2次阅读
没有评论

共计 819 个字符,预计需要花费 3 分钟才能阅读完成。

文件目录:

/wp-content/themes/wordpress-theme-puock-2.8.11/inc/go.php

改造 go.php 文件:

<?php
/**
 * External Link Redirect Page
 *
 * This page handles external link redirections with proper validation,
 * SEO-friendly structure, and crawler accessibility.
 */
include '../../../../wp-blog-header.php';

// 设置状态码为200,确保爬虫能正确索引
status_header(200);
header("HTTP/1.1 200 OK");
// 获取URL参数并处理
$url = $_GET['to'] ?? '';
$name = $_GET['to'] ?? '';

if (!empty($name)) {
    $name = base64_decode(str_replace(' ', '+', $name));
}

pk_set_custom_seo("链接跳转:{$name}");

第二部分:

// 检测是否为爬虫
function is_crawler() {
    $crawlers = array(
        'Googlebot', 'Bingbot', 'Slurp', 'DuckDuckBot', 'Baiduspider',
        'YandexBot', 'Sogou', 'facebookexternalhit', 'ia_archiver'
    );
    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
    foreach ($crawlers as $crawler) {
        if (stripos($user_agent, $crawler) !== false) {
            return true;
        }
    }
    return false;
}

 

正文完
点击链接加入群聊【轩源技术交流群】:https://qm.qq.com/q/xrQ0LCYwTe
post-qrcode
 0
轩源
版权声明:本站原创文章,由 轩源 于2025-03-01发表,共计819字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
支持作者

☝️用微信请我喝杯咖啡☕️

😛如果文章对您有用,请支持作者😛

支持作者

☝️用支付宝请我喝杯奶茶🧋

评论(没有评论)