重定向
重定向的来源路径不能包含像
path#anchor 这样的 URL 锚点,或像 path?query=value 这样的查询参数。目标路径可以包含锚点(例如 /destination/path#section)。docs.json 文件的顶层添加 redirects 字段即可设置重定向。
docs.json
/source/path 重定向到 /destination/path。
默认情况下,重定向为永久重定向 (308)。若要使用临时重定向 (307),请将 permanent 设置为 false。
通配符重定向
*。在此示例中,/beta/:slug* 可匹配 /beta/introduction,并将其重定向到 /v2/introduction。
部分通配符重定向
/articles/concepts- 的 URL,例如 /articles/concepts-getting-started 和 /articles/concepts-overview,并将它们全部重定向到 /collections/overview。
你也可以在目标地址中使用捕获到的通配符值进行替换。
/old/article-123 重定向到 /new/article-123,并在前缀之后保留捕获到的值。