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. Click Upload Rules.

  7. Click Choose File, and navigate to the CSV file to upload.

  8. 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 matchURLand redirectURLcolumns, 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

Category

Usage

Examples

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 Type

CSV Column Name

Action/Description

Required Fields

Rule name

ruleName

Enter a descriptive name for the rule.
This field is required for all rules.

HTTP status code

result.statusCode

For 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 URL

matchURL

For 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 URL

result.redirectURL

For 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.

Optional Fields

Continent Code (Part of User Data Location Match)

continentCode

If 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.

Cookie

cookie

Enter 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)

countryCode

If 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.

Default

matchAlways

Enter 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 Characteristics

deviceCharacteristics

Enter 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 Time

    utcEndTime

    Using 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 Extension

    extension

    Enter 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.

    Hostname

    hostname

    Enter 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 List

    clientip

    Enter 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 Parameters

    result.useIncomingQueryString

    Enter either 0 (false) or 1 (true) to append all query parameters from the source URL to the redirect URL.

    Protocol

    protocol

    Enter either HTTP or HTTPS as the protocol to match on. You can enter the protocol using either uppercase or lowercase letters.

    Proxy

    proxy

    Enter 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 Match

    query

    Enter 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)

    regionCode

    If 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 Match

    regex

    Enter 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 Header

    header

    Enter 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 Method

    method

    Enter the request header to match on. Options include the following: DELETE, GET, HEAD, POST, and PUT.

    Start Time

    utcStartTime

    Using 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 Path

    path

    Enter 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:

    Character

    Use

    "

    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 Type

    Syntax Demonstrated

    Browser version rule

    Escaped spaces (\), wildcards (*), and multiple values (space separated values)

    API Request

    contentType=…

    TextRequest

    contentType:… (use of colon and escaped space)

    contentType exists

    matchOperator=”exists” (CSV: ?)
    Request header name-only, no colon/equals, and no value

    No contentType exists

    Negation (CSV: ‘!’) of header contentType existence


    Did this page help you?