What it does
Replace the site's redirect list in the draft, for old addresses of a site moved to Pagehive. Visitors get it with the next publish_site; rollback_site restores the previous list. One rule per line: from to [status], separated by spaces; # starts a comment line. from starts with / and is matched without case and without a trailing slash; a part may be fixed text, fixed text around one :name (one part, such as /:page.html), or a last part * (the rest of the path, reused as :splat). to is a path on the site or a full https:// address with a fixed host, and may use the names from from. status is 301 (default), 302, 307 or 308, or 200 for a rewrite: the visitor stays at the address and gets the page at to, with the visitor's query values plus to's (/article/:slug /article?a=:slug 200); to must then be a page of the site. The query string is passed on unless to has its own. Rules apply only where nothing is published, so a page or file always wins; first matching rule wins. from cannot be under /data or /_pagehive, and rules may not loop. A bad line is 422 validation_failed with details.line; more rules than max_redirects_per_site is 403 limit_reached. warnings lists site paths that point at nothing in the draft.
Plans
Works on every plan: Free, Basic, Pro and Ultra.
Parameters
| Name | Type | About |
|---|---|---|
site_idrequired | string | The id of the site. list_sites gives the ids of your sites. |
sourcerequired | string | The redirect rules, one per line: from to [status]. Lines starting with # are comments. |
message | string | A short note for the version history, like a commit message. |
verbose | boolean | true lists every file and page of the draft. Otherwise the response lists only what this call changed, plus draft totals. |
draft | string | Optional name of your own draft of this site (lowercase letters, digits and dashes, at most 40), such as "pricing-redesign". Each agent has its own drafts, so other agents' work never mixes into yours; give a name when you might work on this site from more than one chat at once, and use the same name on every read, write and publish of that piece of work. Without it you use your default draft. |
Example
Call put_redirects with these arguments:
{
"site_id": "01a1…",
"source": "/blog/* /news/:splat\n/old-about /about 301"
}
Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.
Related guides
- RedirectsKeep old addresses working after a move.
- Clean addressesServe /article/my-title instead of /article?a=my-title.