Skip to main content

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

ParameterTypeRequiredDescription
serviceIdIntegerMandatoryservice id.

Body Parameters

ParameterTypeRequiredDescription
policyNameStringMandatoryPolicy name for redirection.
matchUrlPathObjectMandatoryURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
redirectDestinationStringMandatorySend an HTTP redirect if this policy matches.
httpCodeIntegerMandatoryHTTP response code to use if sending an HTTP redirect. Could be "301/302".
priorityIntegerMandatoryPriority weight for the rule. Rules with a higher weight take precedence. The weight must be non-zero.
matchQueryStringObjectOptionalQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
enabledBooleanOptionalFlag defining if policy is active or no. Default is true.
Object: Match Url Path
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the field. Supported values:prefix,regex,equals,suffix.
patternsString[]MandatoryList of patterns matching the URL path string.
Object: Match Query String
ParameterTypeRequiredDescription
operatorStringMandatoryDefines how to match the field. Supported values:prefix,regex,equals,suffix.
patternsString[]MandatoryList of patterns matching the URL query string.

Response

Reponse Body

ParameterTypeDescription
policyNameStringPolicy name for redirection.
matchUrlPathObjectURL path matching configuration that determines which requests the rule applies to. See Match Url Path for details.
redirectDestinationStringSend an HTTP redirect if this policy matches.
httpCodeIntegerHTTP response code to use if sending an HTTP redirect. Could be "301/302".
matchQueryStringObjectQuery-string matching configuration used to refine which requests the rule applies to. See Match Query String for details.
priorityIntegerPriority weight for the rule. Rules with a higher weight take precedence. The weight must be non-zero.
enabledBooleanFlag defining if policy is active or no. Default is true.

Object: Match Url Path

ParameterTypeDescription
operatorStringDefines how to match the field. Supported values:prefix,regex,equals,suffix.
patternsString[]List of patterns matching the URL path string.

Object: Match Query String

ParameterTypeDescription
operatorStringDefines how to match the field. Supported values:prefix,regex,equals,suffix.
patternsString[]List of patterns matching the URL query string.

Status Codes, Error Codes and Error Messages

Status CodeError CodeError Message
400Request.BadRequestBad request.
400InvalidCustomer.IdEmptyCustomer id can be empty or invalid.
400InvalidService.IdIncorrectService id is empty or invalid.
400ServiceId.IdPermissionServiceId can not be found or unknown.
400InvalidRedirection.PolicyNamePolicy name is required.
400InvalidRedirection.MatchURLIncorrectThe matchUrlPath can not be empty.
400InvalidRedirection.OperatorOperator must be one of the following: prefix,regex,equals or suffix.
400InvalidRedirection.MatchUrlPathPatternsIncorrectThe MatchUrlPath patterns could not be empty.
400InvalidRedirection.URLEmptyPolicy redirection URL is empty.
400InvalidRedirection.HttpCodeEmptyPolicy redirection http code is empty.
400InvalidRedirection.HttpCodePolicy redirection http code type is 301 or 302.
400InvalidRedirection.PriorityPatterns 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
}