Skip to main content

Edit Redirection V2

This API is used to edit an existing redirection rule for a website acceleration service.

Request

Request-Line

PUT /cdn/v1.1/services/{serviceId}/redirections/{policyId} HTTP/1.1

Request Parameters

Path Parameters

ParameterTypeRequiredDescription
serviceIdIntegerMandatoryThe unique identifier of the service.
policyIdIntegerMandatoryThe unique identifier of the redirection policy.

Body Parameters

ParameterTypeRequiredDescription
policyNameStringMandatoryName of the redirection policy.
matchesArrayMandatoryMatching configuration that determines which requests the rule applies to. See Matches 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: Matches
ParameterTypeRequiredDescription
ArrayMandatorySee Match for details.
Object: Match
ParameterTypeRequiredDescription
fieldStringMandatoryWhich part of the request to match. Supported values:
req.path - Request path (excluding query string).
req.query - Request query parameters.
req.method - HTTP method (GET, POST, etc.).
client.ip - Client IP address.
req.host - Request host.
req.header.user-agent - User-Agent header.
req.header.cookie - Cookie header.
req.header.origin - Origin header.
req.header.via - Via header.
operatorStringMandatoryDefines how to match the field. Supported values:
startswith - Succeeds if the field value matches one of the prefixes listed in patterns.
not_startswith - Matches if field value does not start with any of the specified prefixes.
istartswith - Case-independent version of startswith.
not_istartswith - Matches if the field value does not start with any of the specified prefixes, ignoring letter case differences.
regex - Succeeds if the field value matches one of the regexes listed in patterns.
equals - Succeeds if the field value matches one of the strings listed in patterns.
not_equals - Succeeds if the field value does not exactly match any of the specified strings.
iequals - Case-independent version of equals.
not_iequals - Succeeds if the field value does not exactly match any of the specified strings, ignoring letter case differences.
endswith - Succeeds if the field value ends with one of the strings listed in patterns. Useful e.g. to match file extensions like ".mp4".
not_endswith - Succeeds if the field value does not end with one of the strings listed in patterns.
iendswith - Case-independent version of endswith.
not_iendswith - Succeeds if the field value does not end with one of the strings listed in patterns, ignoring letter case differences.
subnet - Succeeds if the field value belongs to one of subnets, specified in patterns, like "1.222.94.98/32".
not_subnet - Succeeds if the field value does not belong to one of subnets.
Note: subnet operator is applicable only to the client.ip match option.
valuesArrayMandatoryList of values matching the URL path string.

Response

Response Body

ParameterTypeDescription
policyIdIntegerUnique identifier of the created redirection policy.
policyNameStringName of the redirection policy.
matchesArrayMatching configuration for the rule. See Matches for details.
redirectDestinationStringThe destination URL for the redirect.
httpCodeIntegerHTTP status code for the redirect.
priorityIntegerPriority weight of the rule.
enabledBooleanWhether the policy is active.

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.
400InvalidPolicy.MatchesIncorrectMatches cannot be empty or incorrect.
400InvalidPolicy.MatchFieldIncorrectMatch field cannot be empty and must use a valid value.
400InvalidPolicy.MatchOperatorIncorrectMatch operator is required and must use a valid value.
400InvalidPolicy.MatchValuesIncorrectMatch values are required and cannot be empty.
400InvalidPolicy.MatchValueIncorrectAll match values must not be empty.

Examples

Edit Redirection V2

Request

PUT /cdn/v1.1/services/229033/redirections/262286  HTTP/1.1

{
"policyName":"redo",
"matches":[
{
"field":"req.path",
"operator":"startswith",
"values":["/css/","/images/abc/"]
},
{
"field":"req.host",
"operator":"iequals",
"values":["expamle.com"]
}

],
"priority":1,
"redirectDestination":"www.domain333.com",
"httpCode":302,
"enabled":true
}

Successful Response Body

{
"policyId": 262286,
"policyName": "redo",
"redirectDestination": "www.domain333.com",
"httpCode": 302,
"matches": [
{
"field": "req.path",
"operator": "startswith",
"values": [
"/css/",
"/images/abc/"
]
},
{
"field": "req.host",
"operator": "iequals",
"values": [
"expamle.com"
]
}
],
"priority": 1,
"enabled": true
}