> ## Documentation Index
> Fetch the complete documentation index at: https://omer-914cc1c6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 重定向与失效链接

> 防止链接失效的工具

当你更改 docs 文件夹中文件的路径时，该页面的 URL 也会随之更改。这通常发生在重组文档或更改侧边栏标题时。

<div id="broken-links">
  ## 失效链接
</div>

使用我们的命令行界面（CLI）检查并发现失效链接。[安装 CLI](/zh/installation) 后运行以下命令：

```bash theme={null}
mint broken-links
```

命令行界面（CLI）会检测文档中所有指向不存在目标的相对链接。

<div id="redirects">
  ## 重定向
</div>

在你的 `docs.json` 文件中添加 `redirects` 字段来设置 301 重定向。

```json theme={null}
"redirects": [
  {
    "source": "/source/path",
    "destination": "/destination/path"
  }
]
```

这会将 `/source/path` 永久重定向到 `/destination/path`，从而保留原页面既有的 SEO（搜索引擎优化）权重。

要匹配通配路径，请在参数后使用 `*`。在此示例中，`/beta/:slug*` 会匹配 `/beta/introduction`，并将其重定向到 `/v2/introduction`。

```json theme={null}
"redirects": [
  {
    "source": "/beta/:slug*",
    "destination": "/v2/:slug*"
  }
]
```
