Skip to main content

Create Redirection

This API is used to create a redirection rule for a website acceleration service.

Request

Request-Line

POST /cdn/v1.0/services/{serviceId}/redirections HTTP/1.1

Request Parameters

Path Parameters

ParameterTypeRequiredDescription
serviceIdIntegerMandatoryservice id.

Body Parameters

ParameterTypeRequiredDescription
policyNameStringMandatoryName of the redirection policy.
matchUrlPathObjectMandatoryURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
matchQueryStringObjectOptionalQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
redirectDestinationStringMandatoryThe destination URL to redirect to when the policy matches.
httpCodeIntegerMandatoryHTTP status code for the redirect. Supported values: 301, 302.
priorityIntegerMandatoryPriority weight for the rule. Rules with a higher weight take precedence. Must be a positive integer.
enabledBooleanOptionalWhether the policy is active. Default is true.
Object: Match Url Path
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the URL path. Supported values: prefix, regex, equals, suffix.
patternsArrayMandatoryList of patterns to match against the URL path.
Object: Match Query String
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the query string. Supported values: prefix, regex, equals, suffix.
patternsArrayMandatoryList of patterns to match against the query string.

Response

Response Body

ParameterTypeDescription
policyNameStringName of the redirection policy.
matchUrlPathObjectURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
matchQueryStringObjectQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
redirectDestinationStringThe destination URL to redirect to when the policy matches.
httpCodeIntegerHTTP status code for the redirect. Supported values: 301, 302.
priorityIntegerPriority weight for the rule. Rules with a higher weight take precedence. Must be a positive integer.
enabledBooleanWhether the policy is active. Default is true.

Status Codes, Error Codes and Error Messages

Status CodeError CodeError Message
400Request.BadRequestBad request.
400InvalidCustomer.IdEmptyCustomer ID cannot be empty or invalid.
400InvalidService.IdIncorrectService ID is empty or invalid.
400InvalidService.IdPermissionService ID cannot be found or unknown.
400InvalidRedirection.PolicyNamePolicy name is required.
400InvalidRedirection.MatchURLIncorrectThe matches configuration cannot be empty.
400InvalidRedirection.OperatorOperator must be one of the following values: prefix, regex, equals or suffix.
400InvalidRedirection.MatchUrlPathPatternsIncorrectMatch patterns cannot be empty.
400InvalidRedirection.URLEmptyRedirect destination URL is empty.
400InvalidRedirection.HttpCodeEmptyHTTP status code is empty.
400InvalidRedirection.HttpCodeHTTP status code must be 301 or 302.
400InvalidRedirection.PriorityPolicy is 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
}