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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International 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 收工。