Skip to main content

Edge URL redirect

This service speeds up navigation and relieves your origin servers by moving the URL redirection from the origin to an edge server closer to the end users

Overview

When a user enters a URL in their browser to access your website or application, the request first reaches the redirector located at the "edge" of the network—closest to the user—rather than directly reaching the origin server. This service speeds up end-user navigation and relieves your origin servers of non-essential tasks.

Use case:

Website growth and evolution: As your website's structure evolves over time, from blog to a more professional and complete website involving online sales for instance, the list of redirection rules can become extensive as the structure will completely change over time with pages moved to other addresses. It will make redirections increasingly difficult for the origin server to manage efficiently. Offloading redirection management to the edge helps alleviate this burden, enabling the origin server to focus on tasks that cannot be handled at the network edge, thereby improving overall performance.

Benefits

  • Enhanced Speed: Save the round trip between end-user and Origin Server allows faster and more efficient redirection.

  • Relieve Origin Server: Reduced origin server load frees up capacity for other performance-critical tasks that require additional resources.

  • SEO Performance Properly managed redirection is key for strong rankings and visibility on Search Engines.

Configurations

The internal/Client operation team member should configure one parameter named RULES into edge compute ihm

this variables should contains a list of rules into a JSON format. Each rule must have elements

Edge URL Redirect Custom Rule Configuration

This document describes the JSON configuration structure for a custom edge url redirect rule.

Overview

The configuration defines a redirect rule with specific conditions and actions that determine when and how requests should be redirected.

Configuration Properties Quick Reference

CategoryPropertyTypeRequiredDescription
RootnamestringYesHuman-readable name for the rule
RootordernumberYesExecution priority (lower numbers execute first)
RootactionobjectYesDefines the redirect behavior and modifications
RootconditionsobjectNoSpecifies when the rule should be applied
Action - Redirectredirect.status_codenumberNoHTTP status code for the redirect (301, 302). Default 302
Action - Redirectredirect.redirect_urlstringYesTarget URL with optional placeholders like {userId}
Action - Redirectredirect.redirect_typestringYesType of redirect: None/Inherit/Relative
Action - Query Stringsquery_stringsarrayNoQuery parameter modifications (preserve_all, remove_all, remove, modify, add)
Conditions - Timedatetime_startstringNoRule activation start time (ISO Format: yyyy-MM-ddTHH:mm:ss)
Conditions - Timedatetime_endstringNoRule activation end time (ISO Format: yyyy-MM-ddTHH:mm:ss)
Conditions - IPip.negationbooleanYes*Whether to negate the IP condition (*if ip used)
Conditions - IPip.valuearrayYes*List of IP addresses/CIDR blocks (*if ip used)
Conditions - Countriescountries.negationbooleanYes*Whether to negate the country condition (*if countries used)
Conditions - Countriescountries.valuearrayYes*List of country codes (*if countries used)
Conditions - HostnamehostnamestringNoTarget hostname pattern (supports wildcards)
Conditions - URLurl.negationbooleanYes*Whether to negate the URL condition (*if url used)
Conditions - URLurl.valuestringYes*URL pattern to match (*if url used)
Conditions - URLurl.match_typestringYes*Matching method: regex/equals/contains (*if url used)
Conditions - User Agentuser_agent.negationbooleanYes*Whether to negate the user agent condition (*if user_agent used)
Conditions - User Agentuser_agent.valuearrayYes*List of user agent patterns (*if user_agent used)
Conditions - User Agentuser_agent.match_typestringYes*Matching method (*if user_agent used)
Conditions - File Extfile_extensions.negationbooleanYes*Whether to negate the file extension condition (*if file_extensions used)
Conditions - File Extfile_extensions.valuearrayYes*List of file extensions to match (*if file_extensions used)
Conditions - Headersheaders[].header_namestringYes*Name of the header to check (*if headers used)
Conditions - Headersheaders[].negationbooleanYes*Whether to negate the condition (*if headers used)
Conditions - Headersheaders[].match_typestringYes*Matching method: equals/contains/regex (*if headers used)
Conditions - Headersheaders[].valuestringYes*Value to match against (*if headers used)
Conditions - Headers Existheaders_exist[].negationbooleanYes*Whether to negate the condition (*if headers_exist used)
Conditions - Headers Existheaders_exist[].header_namestringYes*Request header name (*if headers_exist used)
Conditions - Query Stringsquery_strings[].negationbooleanYes*Whether to negate the condition (*if query_strings used)
Conditions - Query Stringsquery_strings[].keystringYes*Query string key name (*if query_strings used)
Conditions - Query Stringsquery_strings[].valuestringYes*Value to match (*if query_strings used)
Conditions - Query Stringsquery_strings[].match_typestringYes*Matching method: equals/contains (*if query_strings used)
Conditions - Query Strings Existquery_strings_exist[].negationbooleanYes*Whether to negate the condition (*if query_strings_exist used)
Conditions - Query Strings Existquery_strings_exist[].keystringYes*Query string key name (*if query_strings_exist used)

Root Properties

PropertyTypeRequiredDescription
namestringYesHuman-readable name for the rule
ordernumberYesExecution priority (lower numbers execute first)
actionobjectYesDefines the redirect behavior and modifications
conditionsobjectNoSpecifies when the rule should be applied

Action Configuration

Redirect Settings

PropertyTypeRequiredDescription
redirect.status_codenumberNoHTTP status code for the redirect (301, 302). default 302
redirect.redirect_urlstringYesTarget URL with optional placeholders like {userId}
redirect.redirect_typestringYesType of redirect must be :
None: Requires a fully-qualified URL, with protocol, in the Redirect Path field.
Inherit: Creates an absolute path using the request's protocol and hostname and the path in the Redirect URL field. The response includes this absolute path in its Location header.
Relative:Takes the path entered in the Redirect URL field and sets it in the response’s Location header. The client or browser receiving the request decides which protocol and hostname to use.

Query String Modifications

The query_strings array defines how to modify URL parameters:

Rule TypeDescriptionExample
preserve_allPreserve all query parametersrule_changes: "preserve_all"
remove_allRemoves all query parametersrule_changes: "remove_all"
removeRemoves a specific parameterkey: "token", rule_changes: "remove"
modifyChanges the value of an existing parameterkey: "lang", value: "fr", rule_changes: "modify"
addAdds a new parameterkey: "key3", value: "value3", rule_changes: "add"

Conditions Configuration

Time-based Conditions

PropertyTypeRequiredDescription
datetime_startstringNoRule activation start time (ISO Format Date Time yyyy-MM-ddTHH:mm:ss)
datetime_endstringNoRule activation end time (ISO Format Date Time yyyy-MM-ddTHH:mm:ss)

IP Network Conditions

IP network conditions is an optional condition but when set the following elements must be provided

PropertyTypeRequiredDescription
ip.negationbooleanYesWhether to negate the IP condition
ip.valuearrayYes*List of IP addresses/CIDR blocks (*required if ip condition is used)

Countries Conditions

Countries conditions is an optional condition but when set the following elements must be provided

PropertyTypeRequiredDescription
countries.negationbooleanYesWhether to negate the country condition
countries.valuearrayYes*List of country codes (*required if countries condition is used)

Hostname Condition

PropertyTypeRequiredDescription
hostnamestringNoTarget hostname pattern (supports wildcards)

Request URL Conditions

Request url conditions is an optional condition but when set the following elements must be provided

PropertyTypeRequiredDescription
url.negationbooleanYesWhether to negate the URL condition
url.valuestringYes*URL pattern to match (*required if url condition is used)
url.match_typestringYesMatching method (regex, equals, contains). Support wildcard with regex match_type

User Agent Conditions

User Agent conditions is an optional condition but when set the following elements must be provided

PropertyTypeRequiredDescription
user_agent.negationbooleanYesWhether to negate the user agent condition
user_agent.valuearrayYesList of user agent patterns (*required if user_agent condition is used)
user_agent.match_typestringYesMatching method

File extension Conditions

File extensions conditions is an optional condition but when set the following elements must be provided

PropertyTypeRequiredDescription
file_extensions.negationbooleanYesWhether to negate the file extension condition
file_extensions.valuearrayYes*List of file extensions to match (*required if file_extensions condition is used)

Header Conditions

Headers conditions is an optional array conditions but when setted a json should be provided with these elements

Header Value Matching

PropertyTypeRequiredDescription
header_namestringYesName of the header to check
negationbooleanYesWhether to negate the condition
match_typestringYesMatching method (equals, contains, regex)
valuestringYesValue to match against

Header exist Conditions

Headers exist conditions is an optional array conditions. This conditions check the existance of an request headers. When setted each element should be a json with these elements

PropertyTypeRequiredDescription
negationbooleanYesWhether to negate the file extension condition
header_namestringYes*request header name

Query string exist Conditions

Query String exist conditions is an optional array conditions. This conditions check the existance of an query string from request url. When setted each element should be a json with these elements

PropertyTypeRequiredDescription
negationbooleanYesWhether to negate the file extension condition
keystringYesquery string's key name

Example:

[{
    "name" : "Custom Rule for edge url redirect",
    "order": 1,
    "action": {
        "redirect": {
            "status_code" : 301,
            "redirect_url" : "/page/{userId}/",
            "redirect_type": ""
        },
        "query_strings":[
            {
                "rule_changes": "remove_all"
            },
            {
                "key": "token",
                "rule_changes": "remove"
            },
            {
                "key": "lang",
                "value": "fr",
                "rule_changes": "modify"
            },
            {
                "key": "key3",
                "value": "value3",
                "rule_changes": "add"
            }
        ]
    },
    "conditions": {
         "datetime_start": "",
         "datetime_end": "",
         "hostname": "abdoultest1.cdb-staging.*.orange.com",
         "ip_address":{
            "negation": true,
            "value": ["192.168.1.1/32", "192.168.2.0/24"]
         },
         "countries":{
            "negation": true,
            "value": ["ma", "fr", "en"]
         },
        "url": {
            "negation": true,
            "value": "/page/*/{userId}/home",
            "match_type": "regex"
        },
        "user_agent": {
            "negation": false,
            "value": ["mobile", "mozilla"],
            "match_type": "contains"
        },
        "file_extensions": {
            "negation": false,
            "value": ["jpg", "png", "txt"]
        },
        "headers":[
            {
                "header_name": "Authorization",
                "negation": false,
                "match_type": "contains",
                "value": "Bearer "
            },
            {
                "header_name": "Content-type",
                "negation": false,
                "match_type": "equals",
                "value": "application/json"
            }
        ],
        "headers_exist":[
            {
                "header_name": "Authorization",
                "negation": false
            },
            {
                "header_name": "Content-type",
                "negation": false
            }
        ],
        "query_strings":[
            {
                "negation": false,
                "key": "token",
                "value": "XXXXXXX",
                "match_type": "equals"
            },
            {
                "negation": true,
                "key": "version",
                "value": "XXXXXXX",
                "match_type": "contains"
            }
        ],
        "query_strings_exist":[
            {
                "negation": false,
                "key": "token"
            },
            {
                "negation": true,
                "key": "version"
            }
        ]
    }
}]

Steps to implement Edge URL Redirect with CDB Edge Compute

Prerequisite CDB Edge Compute must be activated for your customer.

  1. Click on the FastEdge icon on the left to switch to FastEdge management.

  2. Select CDN Applications then Applications

  3. Click Create new application visible on top right

  4. Select Edge URL redirect

  5. Enter your settings

  6. Click Save and deploy visible on top right At that point, your edge url redirect application is deployed on FastEdge, now it needs to be called by CDN, additional below steps are then necessary.

  7. Select CDN on left pane

  8. Select the CDN resource you want to associate with the Stickness function

  9. In the CDN resource configuration (OPTIONS) select FastEdge apps

  10. Switch the Enable On request headers

  11. Select your edge Url redirect application from then drop down list displayed by clicking Fastedge application If the Orgin Shielding on your CDN Resource uncheck the Option 'Invoke FastEdge app on shield'.
    If you want to see fastedge log error in case of processing error uncheck the option Interrupt request processing in case of error