惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

记录生活,精彩一刻 - typecho

Typecho 插件推荐 UploadPlugin Typecho-Riven主题正式发售啦 Typecho 已经更新到1.3.0 ,你更新了吗? 分享一个适用于Typecho博客的Robots协议规则 推荐一款特别漂亮的Typecho主题 - 见字 Typecho插件:ImageAccelerator文章图片加速 Typecho开启Gzip压缩加速网站 Typecho 数据库字符集导致Emoji表情评论报错 Typecho 博客自定义右键 Typecho 网站更换域名操作指南 Typecho发布文章时出现的错误
Typecho 站内搜索插件 SiteSearch(BUG)
Huo · 2026-06-13 · via 记录生活,精彩一刻 - typecho

今天早上醒的特别早,也睡不着了,躺着也没啥意思,起来捣鼓博客吧,自从主题及系统升级完后一直还没测试过站内搜索的功能,尝试一下,结果发现问题,这篇文章做个记录。

这个问题不一定其它朋友遇到,但是我是真遇到了,这个博客永久链接地址设置了自定义地址 /archives/{slug}.html 。

搜索完成后,地址链接错误,给出的链接地址还是 https://9sb.net/archives/{slug}.html 不是真实的文章链接地址,随后找 AI 解决一下。

找到插件目录Action.php文件,找到原代码:

    private function formatResult($post, $matchType, $snippet = null)
{
    // 根据类型生成正确的URL
    $type = $post['type'];
    $cid = $post['cid'];
    $slug = isset($post['slug']) ? $post['slug'] : '';
    
    if ($type === 'page') {
        // 独立页面使用slug生成URL
        $url = Typecho_Router::url('page', array('cid' => $cid, 'slug' => $slug));
    } else {
        // 文章使用默认路由
        $url = Typecho_Router::url('post', array('cid' => $cid));
    }
    
    $result = array(
        'title' => $post['title'],
        'url' => $url,
        'date' => date('Y-m-d', $post['created']),
        'matchType' => $matchType,
        'contentSnippet' => $snippet
    );
    
    return $result;
}

直接更换为:

    private function formatResult($post, $matchType, $snippet = null)
{
    $type = $post['type'];
    $slug = isset($post['slug']) ? $post['slug'] : '';
    $siteUrl = rtrim(Helper::options()->siteUrl, '/');

    if ($type === 'page') {
        // 独立页面沿用系统原生路由
        $url = Typecho_Router::url('page', array('cid' => $post['cid'], 'slug' => $slug));
    } else {
        // 文章强制适配自定义永久链接 /archives/{slug}.html
        $url = $siteUrl . '/archives/' . htmlspecialchars($slug) . '.html';
    }

    $result = array(
        'title' => $post['title'],
        'url' => $url,
        'date' => date('Y-m-d', $post['created']),
        'matchType' => $matchType,
        'contentSnippet' => $snippet
    );
    
    return $result;
}

然后再去测试,问题已经解决,OK 收工。