Add Website Redirects (WSM 4.5.7.0+ only)

Add (append) redirects for a given website.

URL

/api/v1/website/[website_id]/redirects

HTTP Method

POST

URL Parameters

Parameter

Required

Type

Description

website_id

true

integer

Specifies the website ID to add redirects to.

Response Parameters

POST requires an array of redirect_details objects. If an empty array is provided, nothing will be changed. If redundant redirects are provided, they will be added–this matches the behavior of the UI. It is up to the API user to avoid creating redundant redirects. A redirect_details object contains the following:

Parameter Type Description
proto string

The scheme being redirected.

"http" → HTTP

"https" → HTTPS

It is an error to specify http for an https-only website, or https for an http-only website.

match_type string

The type of match to perform.

"prefix" → Literal prefix matching path

"regex" → Regular expression matching path

"vhost regex" → Regular expression matching virtual host

match string Content to match.
rd_exernally_to string Full URL to redirect to, including scheme.

Example: Add redirects to website 1

Request

GET

/api/v1/website/1/redirects

cURL

curl -kv \
-u api_ninja:ninja_password \
-X GET \
-d @add_redirects_payload.json \
https://172.31.1.172:4849/api/v1/website/1/redirects

add_redirects_payload.json
[
{
"proto": "http",
"match_type": "prefix",
"match": "/prefix",
"rd_externally_to": "http://example.com/prefix/"
},
{
"proto": "https",
"match_type": "prefix",
"match": "/https-prefix",
"rd_externally_to": "http://example.com/prefix/"
},
{
"proto": "http",
"match_type": "regex",
"match": "\\d+",
"rd_externally_to": "http://example.com/number/"
}
]

Response

{"result":"success"}