Create Redirection
This API is used to create redirection for website acceleration service.
Request
Request-Line
POST /cdn/v1.0/services/{serviceId}/redirections HTTP/1.1
Request Parameters
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| serviceId | Integer | Mandatory | service id. |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| policyName | String | Mandatory | Policy name for redirection. |
| matchUrlPath | Object | Mandatory | URL path matching configuration that determines which requests the rule applies to. See Match Url Path for details. |
| redirectDestination | String | Mandatory | Send an HTTP redirect if this policy matches. |
| httpCode | Integer | Mandatory | HTTP response code to use if sending an HTTP redirect. Could be "301/302". |
| priority | Integer | Mandatory | Priority weight for the rule. Rules with a higher weight take precedence. The weight must be non-zero. |
| matchQueryString | Object | Optional | Query-string matching configuration used to refine which requests the rule applies to. See Match Query String for details. |
| enabled | Boolean | Optional | Flag defining if policy is active or no. Default is true. |
Object: Match Url Path
| Parameter | Type | Required | Description |
|---|---|---|---|
| operator | String | Mandatory | Defines how to match the field. Supported values:prefix,regex,equals,suffix. |
| patterns | String[] | Mandatory | List of patterns matching the URL path string. |
Object: Match Query String
| Parameter | Type | Required | Description |
|---|---|---|---|
| operator | String | Mandatory | Defines how to match the field. Supported values:prefix,regex,equals,suffix. |
| patterns | String[] | Mandatory | List of patterns matching the URL query string. |
Response
Reponse Body
| Parameter | Type | Description |
|---|---|---|
| policyName | String | Policy name for redirection. |
| matchUrlPath | Object | URL path matching configuration that determines which requests the rule applies to. See Match Url Path for details. |
| redirectDestination | String | Send an HTTP redirect if this policy matches. |
| httpCode | Integer | HTTP response code to use if sending an HTTP redirect. Could be "301/302". |
| matchQueryString | Object | Query-string matching configuration used to refine which requests the rule applies to. See Match Query String for details. |
| priority | Integer | Priority weight for the rule. Rules with a higher weight take precedence. The weight must be non-zero. |
| enabled | Boolean | Flag defining if policy is active or no. Default is true. |
Object: Match Url Path
| Parameter | Type | Description |
|---|---|---|
| operator | String | Defines how to match the field. Supported values:prefix,regex,equals,suffix. |
| patterns | String[] | List of patterns matching the URL path string. |
Object: Match Query String
| Parameter | Type | Description |
|---|---|---|
| operator | String | Defines how to match the field. Supported values:prefix,regex,equals,suffix. |
| patterns | String[] | List of patterns matching the URL query string. |
Status Codes, Error Codes and Error Messages
| Status Code | Error Code | Error Message |
|---|---|---|
| 400 | Request.BadRequest | Bad request. |
| 400 | InvalidCustomer.IdEmpty | Customer id can be empty or invalid. |
| 400 | InvalidService.IdIncorrect | Service id is empty or invalid. |
| 400 | ServiceId.IdPermission | ServiceId can not be found or unknown. |
| 400 | InvalidRedirection.PolicyName | Policy name is required. |
| 400 | InvalidRedirection.MatchURLIncorrect | The matchUrlPath can not be empty. |
| 400 | InvalidRedirection.Operator | Operator must be one of the following: prefix,regex,equals or suffix. |
| 400 | InvalidRedirection.MatchUrlPathPatternsIncorrect | The MatchUrlPath patterns could not be empty. |
| 400 | InvalidRedirection.URLEmpty | Policy redirection URL is empty. |
| 400 | InvalidRedirection.HttpCodeEmpty | Policy redirection http code is empty. |
| 400 | InvalidRedirection.HttpCode | Policy redirection http code type is 301 or 302. |
| 400 | InvalidRedirection.Priority | Patterns cannot be empty or invalid. |
Examples
Create Redirection
Request
POST /cdn/v1.0/services/228657/redirections HTTP/1.1
{
"policyName":"redo",
"matchUrlPath":{
"operator":"prefix",
"patterns":["/"]
},
"matchQueryString":{
"operator":"prefix",
"patterns":["/"]
},
"priority":1,
"redirectDestination":"www.domain333.com",
"httpCode":302,
"enabled":true
}
Successful Response Body
{
"policyId": 261957,
"policyName": "redo",
"redirectDestination": "www.domain333.com",
"httpCode": 302,
"matchUrlPath": {
"operator": "prefix",
"patterns": [
"/"
]
},
"matchQueryString": {
"operator": "prefix",
"patterns": [
"/"
]
},
"priority": 1,
"enabled": true
}