mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
db3ca0500d
* update skills * update migration guide * update API migration guide * update assistant page * update analytics page * update CLI commands * deprecate openapi-check * add coming soon * update docs.json * add index page * add install page * add preview page * add analytics * add commands reference * update links * delete installation.mdx * add optional prereq steps * Add telemetry section to commands reference Incorporates telemetry content from #5039 which was merged to main after this branch was created. Documents opt-out flags, env variables, and config persistence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * move global flags to top * vale * remove `mint upgrade` * remove unnecessary prereq * restructure analytics commands --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
107 lines
2.5 KiB
Plaintext
107 lines
2.5 KiB
Plaintext
---
|
|
title: "Redirects"
|
|
description: "Set up URL redirects for moved, renamed, or deleted documentation pages to preserve SEO rankings and prevent broken links."
|
|
keywords: ["redirects"]
|
|
---
|
|
|
|
When you change the path of a file in your docs folder, it also changes the URL path to that page. This may happen when restructuring your docs or changing the sidebar title.
|
|
|
|
## Redirects
|
|
|
|
<Note>
|
|
Redirects **cannot** include URL anchors like `path#anchor` or query parameters like `path?query=value`.
|
|
</Note>
|
|
|
|
Set up redirects by adding the `redirects` field to your `docs.json` file.
|
|
|
|
```json
|
|
"redirects": [
|
|
{
|
|
"source": "/source/path",
|
|
"destination": "/destination/path"
|
|
}
|
|
]
|
|
```
|
|
|
|
This redirects `/source/path` to `/destination/path`.
|
|
|
|
By default, redirects are permanent (308). To use a temporary redirect (307), set `permanent` to `false`.
|
|
|
|
```json
|
|
"redirects": [
|
|
{
|
|
"source": "/source/path",
|
|
"destination": "/destination/path",
|
|
"permanent": false
|
|
}
|
|
]
|
|
```
|
|
|
|
Both 307 and 308 preserve the HTTP method of the original request (unlike 301 and 302), making them suitable for redirecting POST requests.
|
|
|
|
### Wildcard redirects
|
|
|
|
To match a wildcard path, use `*` after a parameter. In this example, `/beta/:slug*` matches `/beta/introduction` and redirects it to `/v2/introduction`.
|
|
|
|
```json
|
|
"redirects": [
|
|
{
|
|
"source": "/beta/:slug*",
|
|
"destination": "/v2/:slug*"
|
|
}
|
|
]
|
|
```
|
|
|
|
### Partial wildcard redirects
|
|
|
|
Use partial wildcards to match URL segments that start with a specific prefix.
|
|
|
|
```json
|
|
"redirects": [
|
|
{
|
|
"source": "/articles/concepts-*",
|
|
"destination": "/collections/overview"
|
|
}
|
|
]
|
|
```
|
|
|
|
This matches any URLs with the `/articles/concepts-` path, such as `/articles/concepts-getting-started` and `/articles/concepts-overview`, and redirects them all to `/collections/overview`.
|
|
|
|
You can also substitute the captured wildcard value in the destination.
|
|
|
|
```json
|
|
"redirects": [
|
|
{
|
|
"source": "/old/article-*",
|
|
"destination": "/new/article-*"
|
|
}
|
|
]
|
|
```
|
|
|
|
This redirects `/old/article-123` to `/new/article-123`, preserving the captured value after the prefix.
|
|
|
|
### Avoid infinite redirects
|
|
|
|
To avoid infinite loops, do not create circular redirects where paths redirect back to each other.
|
|
|
|
```json
|
|
"redirects": [
|
|
{
|
|
"source": "/docs/:slug*",
|
|
"destination": "/help/:slug*"
|
|
},
|
|
{
|
|
"source": "/help/:slug*",
|
|
"destination": "/docs/:slug*"
|
|
}
|
|
]
|
|
```
|
|
|
|
## Check for broken links
|
|
|
|
Find broken links with the [CLI](/cli).
|
|
|
|
```bash
|
|
mint broken-links
|
|
```
|