Abilities

Create Redirect

lh-url-redirects/create-redirect

Creates a network URL redirect or 410 Gone rule for a source URL on any host, mapped to a site or not. Rules apply only when the source would otherwise 404, or to the root of a domain no site is mapped to. Refuses a duplicate source (same match type, host and path) and a target equal to the source. Returns the saved rule. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
source_urlstringYesAbsolute URL to match, e.g. https://example.org/old-page/. Only host and path count: scheme, query string and trailing slash are ignored. The host need not belong to any site on the network.
match_typestringNoexact (default) matches the path only; prefix matches the path and everything below it, and the path "/" matches the whole host. The longest prefix wins, and an exact rule beats any prefix. One of: exact, prefix.
status_codeintegerNoResponse code. Default 301. 410 sends Gone and ignores target_url. One of: 301, 302, 303, 307, 308, 410.
target_urlstringNoAbsolute http(s) URL to redirect to, on any domain. Required unless status_code is 410.
notestringNoOptional note on why the rule exists.
task_idintegerNoOptional. The lh-tasks task this call is working on. Pass with claim_token: the call is refused unless you hold that claim, and a successful call renews it.
claim_tokenstringNoOptional. The claim_token from claim-next-task for task_id. Required when task_id is given.

Delete Redirect

lh-url-redirects/delete-redirect Destructive Idempotent

Permanently deletes a network URL redirect or 410 rule by id, so its source 404s again. Returns the deleted rule so it can be recreated with create-redirect if needed. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
idintegerYes
task_idintegerNoOptional. The lh-tasks task this call is working on. Pass with claim_token: the call is refused unless you hold that claim, and a successful call renews it.
claim_tokenstringNoOptional. The claim_token from claim-next-task for task_id. Required when task_id is given.

Get Redirect

lh-url-redirects/get-redirect Read-only Idempotent

Gets one network URL redirect or 410 rule by its id, with its hit count and last hit. Use list-redirects to find ids, or resolve-url to find the rule a URL would hit. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
idintegerYes

Import Legacy Redirects

lh-url-redirects/import-legacy-redirects Idempotent

Imports the published rules of the retired lh-response-handler plugin into the network redirect table. Dry run by default: reports what each Response post would become without writing. Safe to rerun, since posts already imported are skipped by their legacy id, as are sources that duplicate an existing rule. The old posts are left untouched. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
dry_runbooleanNotruetrue (default) only reports; false writes the rules.
task_idintegerNoOptional. The lh-tasks task this call is working on. Pass with claim_token: the call is refused unless you hold that claim, and a successful call renews it.
claim_tokenstringNoOptional. The claim_token from claim-next-task for task_id. Required when task_id is given.

List Redirects

lh-url-redirects/list-redirects Read-only Idempotent

Lists network URL redirect and 410 rules, filtered by host, site, status code or text. Returns rules sorted by host then path, with hit counts, plus the total matching. search matches path, target or note. site_id 0 lists rules for domains no site is mapped to. Pages with limit (max 500) and offset. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
hoststringNoOnly rules for this host, e.g. princesparktouch.com.
site_idintegerNoOnly rules whose source belongs to this network site; 0 for unmapped domains.
status_codeintegerNoOnly rules with this response code.
searchstringNoText to find in the source path, target URL or note.
limitintegerNo100
offsetintegerNo0

Resolve URL

lh-url-redirects/resolve-url Read-only Idempotent

Shows which network redirect rule, if any, a URL would hit, without counting a hit. Applies the same matching as live requests: exact path first, then the longest prefix on that host. A rule only fires live when the URL would otherwise 404, which this does not check. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
urlstringYesAbsolute URL to test.

Update Redirect

lh-url-redirects/update-redirect Idempotent

Changes an existing network URL redirect or 410 rule by id; fields left out keep their values. Hit counts are kept. Refuses a change that would duplicate another rule's source. Returns the updated rule. Requires install_plugins; main site only.

ParameterTypeRequiredDefaultDescription
idintegerYes
source_urlstringNoAbsolute URL to match, e.g. https://example.org/old-page/. Only host and path count: scheme, query string and trailing slash are ignored. The host need not belong to any site on the network.
match_typestringNoexact (default) matches the path only; prefix matches the path and everything below it, and the path "/" matches the whole host. The longest prefix wins, and an exact rule beats any prefix. One of: exact, prefix.
status_codeintegerNoResponse code. Default 301. 410 sends Gone and ignores target_url. One of: 301, 302, 303, 307, 308, 410.
target_urlstringNoAbsolute http(s) URL to redirect to, on any domain. Required unless status_code is 410.
notestringNoOptional note on why the rule exists.
task_idintegerNoOptional. The lh-tasks task this call is working on. Pass with claim_token: the call is refused unless you hold that claim, and a successful call renews it.
claim_tokenstringNoOptional. The claim_token from claim-next-task for task_id. Required when task_id is given.