pagehive

put_redirects

Replace the site's redirect list in the draft, for old addresses of a site moved to Pagehive.

Draft contentChanges dataAll plans

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. 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

NameTypeAbout
site_idrequiredstringThe id of the site. list_sites gives the ids of your sites.
sourcerequiredstringThe redirect rules, one per line: from to [status]. Lines starting with # are comments.
messagestringA short note for the version history, like a commit message.
verbosebooleantrue lists every file and page of the draft. Otherwise the response lists only what this call changed, plus draft totals.

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.