> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-mintlify-add-hello-world-quickstart-48843.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 重定向与失效链接

> 帮助预防无效链接的工具

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

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

使用我们的命令行工具检查无效链接。[安装命令行工具](/zh/installation)并运行以下命令：

```bash
mint broken-links
```

命令行工具会识别文档中不存在的相对链接。

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

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

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

这会将 `/source/path` 永久重定向到 `/destination/path`，以避免丢失原页面累积的 SEO 成效。

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

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