Upload rule in CSV format

Instead of using the GUI to add rules, follow this procedure to add rules using CSV upload.

How to

  1. Review the CSV file that contains the rules, and verify that the information is accurate and conforms to the required format.

  2. Go to > CDN > Edge logic Cloudlets.

  3. On the Cloudlet Policies screen, click the name of the policy you want to add rules to.

  4. On the Policy Details screen, click the version of the policy you want to update.

  5. On the rule manager screen, click Upload Rules.

  6. Review the following explaining the purpose of the Overwrite Existing? check box.

    🚧

    Overwriting Rules

    When you upload rules and check Overwrite Existing?, rules currently in the Rule List are overwritten (refer to the following figure).

    If Overwrite Existing? is unchecked (disabled), the rules in the Rule List are not overwritten and the rules in the CSV file are added to the list. You will receive warnings if there are duplicated rules.

    Check (enable) Overwrite Existing? if the rules in the Rule List are not required or if they are required but included in your CSV file.

  1. Click Choose File and navigate to the CSV file to upload.
  2. Once the upload is successful, verify that the rules are in your desired order.

Upload validation rules

These validation rules apply when you upload Cloudlets rules with a CSV file:

  • The first row is a header row and is always ignored.

  • In the matchURL and redirectURL columns, you can use quotation marks to preserve commas.

  • Rules added using CSV upload are added to end of the current list of rules.

Rule syntax

When you upload Cloudlets rules using a CSV file, you use a special syntax. This syntax is also in the CSV rule you receive when you download rules.

Valid delimiter

When entering multiple values for a data type, use a space as a delimiter.

Literal usage of spaces

If you want to use a space in your CSV file, you need to type a backslash (\) first. For example, to upload a rule named "Q1 Sales Site", you would enter it this way: Q1\ Sales\ Site.

Basic CSV file syntax

CategoryUsageExamples
Pattern Matching
CasCase Sensitivity: <value1> <value2>

Note: Applies to match type values, not the whole rule.
ruleName, matchURL, query, result.redirectURL, result.statusCode rule 1, https://example.com, :product=ER VP, https://cloudlets.com, 302
Wildcards* or ?ruleName, matchURL, query,result.redirectURL, result.statusCode rule 1, https://example.com, product=E* FR, https://cloudlets.com, 302
Operators
Is one of (equals)<value1> <value2>...ruleName, matchURL, query,result.redirectURL, result.statusCode rule 1, http://example.com, product=ER FR, http://example2.com, 302
Is not one of (does not equal)!<value1> <value2>...

Note: Applies to match type values, not the whole rule.
ruleName, matchURL, query,result.redirectURL, result.statusCode rule 1, http://example.com, !product=ER FR, http://example2.com, 302
Contains any of*<value1>* *<value2>*...

Note: Applies to match type values, not the whole rule.
ruleName, matchURL, query,result.redirectURL, result.statusCode rule 1, http://example.com, product=*ER* *FR*, http://example2.com, 302
Does not Contain any of!*<value1>* *<value2>*...

Note: Applies to match type values, not the whole rule.
ruleName, matchURL, query,result.redirectURL, result.statusCode rule 1, http://example.com, !product=*ER* *FR*, http://example2.com, 302
And<value1> & <value2>...

Important: Only applies to these match types: cookie, extension, header, hostname, path, and query.

Fields for rule uploads and downloads

The following are the fields available when setting up the syntax for CSV-based rules or downloading rules.

Data TypeCSV Column NameAction/Description
Required Fields
Rule nameruleNameEnter a descriptive name for the rule.
This field is required for all rules.
HTTP status coderesult.statusCodeFor Edge Redirector, enter the status code for the type of redirect this rule supports. Options include:
  • 301: a permanent redirect.
  • 302: a temporary redirect
Source URLmatchURLFor Edge Redirector, enter the name of the source, or inbound, URL.

Enter the full web address that you are redirecting, including the protocol. For example: http://www.example.com. You can use the * wildcard with this data type.
Redirect URLresult.redirectURLFor Edge Redirector, enter the HTTP- or HTTPS-based URL to redirect to if the rule is true.

Enter the full web address you are redirecting the source URL to, including the protocol. For example: http://www.example2.com. You can use regular expressions with this data type.

Option: If you want the protocol and hostname from the incoming request to be used in the Redirect URL, add a column to your .csv called; result.useIncomingSchemeAndHost and enter 1 for the value. In the result.redirectURL column, enter a path. For example; /new.

Option: If you want to use a relative URL and have the client or browser receiving the request decide which protocol and hostname to use, add a column to your .csv called; result.useRelativeUrl and enter relative_url for the value. In the result.redirectURL column, enter a relative path. For example; /relativepath.
Optional Fields
Continent Code (Part of User Data Location Match)continentCodeIf applicable, enter the appropriate continent code in uppercase letters to match based on continent.

For this match type, you can also select whether to use the client IP address from the connecting IP address (CONNECTING_IP), the X-Forwarded-For header value (XFF_HEADERS), or either option.

For example, enter this to select one continent and both client IP options: NA;CONNECTING_IP XFF_HEADERS.

Note the spaces used between multiple values and the semicolon separating the data types.
CookiecookieEnter a cookie to match on using the following format: CookieName = value.

For example: cookie1=yes.

You can use the * and ? wildcards with this match type.
Country Code (Part of User Data Location Match)countryCodeIf applicable, enter the appropriate country code in uppercase letters to match based on country.

For this match type, you can also select whether to use the client IP address from the connecting IP address (CONNECTING_IP), the X-Forwarded-For header value (XFF_HEADERS), or either option.

For example, enter this to select one country and both client IP options: US;CONNECTING_IP XFF_HEADERS

Note the spaces used between multiple values and the semicolon separating the data types.
DefaultmatchAlwaysEnter 1 (true) to match on all incoming requests.

This match type is particularly useful at the end of a rule list. If none of the other rules in the list produce a match, then you can use the default match type to treat the remaining traffic in a particular way.
Device CharacteristicsdeviceCharacteristicsEnter one of these device characteristics to match on:

  • accept_third_party_cookie
  • ajax_support_javascript
  • cookie_support
  • full_flash_support
  • is_mobile
  • is_tablet
  • is_wireless_device

  • When creating a true match, enter only the name of the device characteristic.To create a false match, add an exclamation point in front of the device characteristic’s name. For example: ! accept_third_party_cookie.
    End TimeutcEndTimeUsing the UTC format, enter the end date and time for the rule in seconds. Enter 0 if you do not want the rule to expire.

    If you enter a value in this field other than “0”, you must enter a value greater than “0” in the utcStartTime column.
    File ExtensionextensionEnter the file extension(s) to match on. You do not need to enter the period before the extension. For example: jpg png.

    Note: When entering multiple values, separate them with a space.
    HostnamehostnameEnter the hostname to match on. Include the domain but exclude the protocol. For example: www.example.com. You can use the * wildcard with this match type.
    IP address or CIDR ListclientipEnter an IP address or CIDR list to match on. For example: 122.122.122.0 192.168.2.0/24

    When entering multiple values, separate them with a space. You are limited to 8192 characters.

    For this match type, you can also select whether to use the client IP address from the connecting IP address (CONNECTING_IP), the X-Forwarded-For header value (XFF_HEADERS), or either option.

    For example, enter this to select one IP address and both client IP options: 122.122.122.0;CONNECTING_IP XFF_HEADERS

    Note the spaces between multiple values and the semicolon separating the data types.
    Pass Query Parametersresult.useIncomingQueryStringEnter either 0 (false) or 1 (true) to append all query parameters from the source URL to the redirect URL.
    ProtocolprotocolEnter either HTTP or HTTPS as the protocol to match on. You can enter the protocol using either uppercase or lowercase letters.
    ProxyproxyEnter the type of proxy to match on. Values include anonymous, transparent, or both.

    While anonymous proxy servers hide the originating IP address, transparent proxy servers include the originating IP address in the X-Forwarded-For (XFF) value in the HTTP header.

    For this match type, you can also select whether to use the client IP address from the connecting IP address (CONNECTING_IP), the X-Forwarded-For header value (XFF_HEADERS), or either option.

    For example, enter this to select both options for proxy and client IP: anonymous transparent;CONNECTING_IP XFF_HEADERS.

    Note the spaces between the values and the semicolon between the data types.
    Query String Parameter MatchqueryEnter the query string to match on using the following format: QueryStringName = value.

    For example: name=sales.

    Note: You can use the * wildcard with this match type.
    Region Code (Part of User Data Location Match)regionCodeIf applicable, enter the appropriate region code in uppercase letters. Region code matches are based on a region, like a state or a province, within a country.

    For this match type, you can also select whether to use the client IP address from the connecting IP address (CONNECTING_IP), the X-Forwarded-For header value (XFF_HEADERS), or both options.

    For example, enter this to select one region/state and both client IP options: NY;CONNECTING_IP XFF_HEADERS

    Note the spaces between the values and the semicolon between the data types.
    Regular Expression MatchregexEnter a single URL-based regular expression (regex) to match on. A single CVS rule cannot contain multiple regex values.

    For example: ^https?://www.(vanity|vanity1).com/(.*)

    Note: When using a regular expression match with Edge Redirector, the Redirect URL (result.redirectURL) can include capture groups. For example: \1:// www.company.com/\2/\3 .

    Path and Query String (result.pathAndQS) can include capture groups. /\1/\2
    Request HeaderheaderEnter the request header to match on using the following format: RequestHeader : value.

    For example: Accept: text/html

    Note: Separate the request header type and value with a colon (:), not an equals sign.

    Note: You can use the * and ? wildcards with this match type.
    Request MethodmethodEnter the request header to match on. Options include the following: DELETE, GET, HEAD, POST, and PUT.
    Start TimeutcStartTimeUsing the UTC format, enter the starting date and time for the rule in seconds. Enter 0 to always apply the rule.

    If you enter a value in this field other than “0”, you must enter a value greater than “0” in the utcEndTime column.
    URL PathpathEnter the URL path to match on. Include the leading slash but omit any training slashes. For example: /Q1Sale/images.

    Note: You can use the * wildcard with this match type.

    Character considerations for rule upload

    Special character support

    You can use these characters for inbound/source URL matches:

    { } | \ ^ [ ] `

    Invalid characters

    Do not use the following characters in the CSV file you create for rule upload. They are invalid:

    <>@\¡
    ¢£¤¥¦§
    ¨©ª«¬'
    ®°±²³
    ´µ·¸¹
    ¹º»¼½¾
    ¿ÀÁÂÃÄ
    ÅÆÇÈÉÊ
    ËÌÍÎÏÐ
    ÑÒÓÔÕÖ
    ×ØÙÚÛÜ
    ÝÞßàáâ
    ãäåæçè
    éêëìíî
    ïðñòóô
    õö÷øùú
    ûüýþÿ

    In addition, Unicode Private Use Area (PUA) characters are also invalid.

    Characters with special uses

    When setting up your CSV file for rule upload, the following characters have special uses:

    CharacterUse
    "Encapsulates strings in field values.
    #Denotes a comment when used at the start of a line, or when preceded by a space anywhere in a line. All other instances of this character is treated as a literal.

    Valid Usage

    Here is an example of a CSV file with valid comments:
    ruleName,regex,result.redirectURL,result.statusCode
    Rule3, http://example.com, http://example-new.com#redirect, 301
    # For Rule3, the “#redirect” does not need to be escaped in CSV.

    Invalid Usage

    ruleName,regex,result.redirectURL,result.statusCode
    Rule #1, http://example.com, http://example-new.com, 301
    Rule2, http://example-shop.com, http://example-newshop.com, 301 \#
    # Everything after “Rule “ in the above rule is treated as a comment.
    # The “\#” in Rule2 is not a comment.

    CSV rule file examples

    Edge Redirector CSV example

    Here's an example of a CSV file for uploading Edge Redirector Cloudlet rules:

    Request Header match example

    Here is an example of a CSV file that includes rules using the Request Header match type:

    This table summarizes the syntax demonstrated in each of these rules:

    Rule TypeSyntax Demonstrated
    Browser version ruleEscaped spaces (\), wildcards (*), and multiple values (space separated values)
    API RequestcontentType=…
    TextRequestcontentType:… (use of colon and escaped space)
    contentType existsmatchOperator=”exists” (CSV: ?)
    Request header name-only, no colon/equals, and no value
    No contentType existsNegation (CSV: ‘!’) of header contentType existence