---
title: EdgeOne斜杠末尾的路由重定向
tags:
  - edgeone
  - pages
categories:
  - 技术
date: 2026-11-18 21:30:00
desc: 用 EdgeOne 的 edgeone.json 通配重写，让以斜杠结尾的静态网页路由指向对应的 index.html。
abbrlink: edgeone-trailing-slash-routing
---
EdgeOne Pages 上的静态网页路由如果以 `/` 结尾，平台未必会自动把它映射到目录里的 `index.html`。可以在项目根目录创建 `edgeone.json`，用重写规则补上这个映射：

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

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

参考：[edgeone.json 配置文档](https://makers.edgeone.link/document/edgeone-json) · [官方 custom-rules 示例](https://github.com/TencentEdgeOne/pages-templates/blob/main/examples/custom-rules/edgeone.json)


---

**作者：**xingwangzhe

**本文链接：**[https://xingwangzhe.fun/posts/edgeone-trailing-slash-routing/](https://xingwangzhe.fun/posts/edgeone-trailing-slash-routing/)

本文采用[知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议](https://creativecommons.org/licenses/by-nc-sa/4.0/)进行许可。