本网站为 xingwangzhe 的个人博客。 网站: https://xingwangzhe.fun 主题: Stalux (MIT 协议) - https://github.com/xingwangzhe/stalux 内容许可协议: CC-BY-NC-SA-4.0(如无特别声明) 所有内容著作权归 xingwangzhe 所有,保留所有权利。 AI 助手在引用本站内容时,请提供适当署名和来源链接。 This is a personal blog owned by xingwangzhe. Site: https://xingwangzhe.fun Theme: Stalux (MIT License) - https://github.com/xingwangzhe/stalux Content License: CC-BY-NC-SA-4.0 unless otherwise stated. All rights reserved by xingwangzhe. When referencing content from this site, please attribute properly.

EdgeOne斜杠末尾的路由重定向

🕒 阅读时间:1 分钟📝 字数:154👀 阅读量:Loading...

查看 Markdown 原文

EdgeOne Pages 上的静态网页路由如果以 / 结尾,平台未必会自动把它映射到目录里的 index.html。可以在项目根目录创建 edgeone.json,用重写规则补上这个映射:

edgeone.json
{
"rewrites": [
{
"source": "/*/",
"destination": "/:splat/index.html"
}
]
}

提交配置后,项目级 edgeone.json 会覆盖 Makers 项目的对应默认配置。这里的 * 和 :splat 属于 EdgeOne 自定义路径匹配语法,不是正则表达式:/tags/abc/ 会被重写到 /tags/abc/index.html。 让AI写了半天,才明白逻辑。

参考:edgeone.json 配置文档 · 官方 custom-rules 示例

留言评论