Redirect operations
2 operations named redirects.*. Every one runs in a batch through apply_ops, dry_run_ops, the CLI or the admin.
| Operation | What it does | Permission | Confirmation |
|---|---|---|---|
| redirects.read | Read the draft redirects of the site: the list redirects.update replaces, each { from, to, status }. | site.read | none |
| redirects.update | Replace the site's redirects with redirects, the whole list (at most 500; an empty list removes them all). | site.edit | none |
redirects.read
Read the draft redirects of the site: the list redirects.update replaces, each { from, to, status }. The public site answers the redirects of its published version.
Example input
{}Input
The input is a record; see the schema below.
{
"type": "object",
"properties": {},
"additionalProperties": false
}Output
| Field | Type | Required | Notes |
|---|---|---|---|
| redirects | array of object | yes | At most 500 items. |
| redirects[].from | string | yes | At most 2048 characters. |
| redirects[].to | string | yes | At most 2048 characters. |
| redirects[].status | 301 | 302 | yes |
Try it
yarn splash redirects.read '{}' --dry-runredirects.update
Replace the site's redirects with redirects, the whole list (at most 500; an empty list removes them all). Each rule is { from, to, status }: from a path of this site, matched exactly with or without a trailing slash, or ending in /* to take that path and every path under it (/old/* takes /old and /old/a/b; an exact rule wins over a prefix, a longer prefix over a shorter one); to a path of this site (a query or a hash may follow; a request's query is kept when to has none) or an https:// address; status 301 (moved for good) or 302 (moved for now). A locale's paths carry its prefix (/en/old). Refused with 422 redirects_invalid, every problem named: two rules with the same from, a loop (a target that a rule of the chain redirects again), or a rule that adds or changes a from on the path of a published page (unpublish the page or change its address first; an item path of a collection page is not checked). The platform's own paths (/admin, /api, /_…) are refused. Redirects are versioned: the public site answers them, before any page renders, after the next publish; undo restores the previous list.
Example input
{
"redirects": [
{
"from": "/old-about",
"to": "/about",
"status": 301
},
{
"from": "/shop/*",
"to": "https://shop.example.com/",
"status": 302
}
]
}Input
| Field | Type | Required | Notes |
|---|---|---|---|
| redirects | array of object | yes | At most 500 items. |
| redirects[].from | string | yes | At most 2048 characters. |
| redirects[].to | string | yes | At most 2048 characters. |
| redirects[].status | 301 | 302 | yes |
Output
| Field | Type | Required | Notes |
|---|---|---|---|
| redirects | array of object | yes | At most 500 items. |
| redirects[].from | string | yes | At most 2048 characters. |
| redirects[].to | string | yes | At most 2048 characters. |
| redirects[].status | 301 | 302 | yes |
Try it
yarn splash redirects.update '{"redirects":[{"from":"/old-about","to":"/about","status":301},{"from":"/shop/*","to":"https://shop.example.com/","status":302}]}' --dry-runGenerated from the operation registry and the MCP tool catalogue (source 12f91a6db01e2760).
Something wrong on this page? Write to docs@librettocms.com.