Triggers and markers reference

Triggers define the way redirection.io agents will match incoming requests before performing an action.

The URL trigger

Triggers are based on the incoming url, and can be defined as a simple url (for example /some/page.html) or a pattern (for example "match all URLs of the form /shop/products.php?id=<INTEGER>).

You can create the Trigger of your Rule in the first step of the Rule creation form:

URL trigger

Triggers are a powerful way to define several actions at once, based on patterns. For example, a redirection can be used to redirect all the urls of the form /shop/products.php?id=<INTEGER> to /shop/clothes/product-<INTEGER>.html, with the status code of your choice. Of course, the rules can embed much more complexity, based on the requirements you choose to apply on the markers.

Under the hood, we use regular expressions to match incoming URLs, but you won't have to write manually these regular expressions. You can instead use our graphical expressions builder, which allows to express complex requirements in a simple way.

Creating a marker

Defining a marker is quite simple:

  1. Add marker buttonclick on the "Add marker" button. A modal window appears, with three tabs.
  2. Marker metadata tabSpecify the marker's informations in the "Metadata" tab (name and description of the marker) - this will allow to remind yourself the goal of the marker;
  3. Marker restrictions tabThe "Restrictions" tab allows to define the marker type and characteristics. You can for instance define string markers, containing only uppercase letters and starting with the FOO string.
  4. Marker transformations tab"Transformations" are an easy way to transform the matched values for reusing them later on, in actions.

Once the marker is created, you can go on and use its value in the "Actions" part of the rule. You can also simply use this marker to match a lot of incoming URLs, without using the marker's value (for instance, you could want to create a "Page not available" action for all the requests of the form /wp-admin/<WHATEVER>.

Markers types

redirection.io supports a quite large variety of URL markers:

date

The date type stands for a full-date, as per rfc3339.

  • Example: 2018-07-15
  • Options: none

datetime

The datetime type stands for a date-time, as per rfc3339.

  • Examples:
    • 2018-07-15T14:59:12Z
    • 2018-07-15T14:59:12+02:00
    • 2018-07-15T14:59:12.52Z
  • Options: none

enum

The enum type allows to list exact accepted values.

  • Examples:
    • cat
    • dog
    • fish
    • it can be multiple words
  • Options:
    • Values (required): Just type the character or word that the marker must match, and press "enter".

integer

The integer type matches positive integer values (aka. natural numbers).

  • Examples:
    • 1
    • 42
    • 67638
  • Options:
    • Minimum (optional): You may define a minimal value for the marker to match. For instance, if you type 404 in the "minimum" field, the values 405 and 1234 will be match, but not 88 nor 403. This bound is inclusive (which means, with the previous example, that 404 will be matched).
    • Maximum (optional): You may define a maximal value for the marker to match. For instance, if you type 404 in the "maximum" field, the values 88 and 403 will match, but not 405 or 1234. This bound is inclusive (which means, with the previous example, that 404 will be matched).

regex

This type allows to define advanced matching expressions based on regular expressions. This is of course the most versatile way of creating markers, as it can help create very complex matching expressions.

  • Examples:
    • [a-z0-9_-]{3,16}
    • (\d)+
  • Options:
    • Regex (required): Type here the regular expression that you want to use during the matching

string

The string type allows to define textual markers, which is the most common case for defining markers. This type should cover most of the matching cases, this is the reason why it is auto-selected when you create a new marker.

We support the full utf-8 range, which means that you can match regular ascii chars, but also emojis or specific alphabetical characters.

  • Examples:
    • string
    • h3llo
    • with-specific.chars
    • nón-asçii-chars-Ě-Dž
  • Options:
    • lowercase letters (optional): Check this checkbox to match strings containing lowercase letters, as defined in the Unicode General Category Ll.
    • uppercase letters (optional): Check this checkbox to match strings containing uppercase letters, as defined in the Unicode General Categories Lu and Lt
    • digits (optional): Check this checkbox to match strings containing digits (0, 1, 2, ... 9)
    • percent-encoded-chars (optional): Check this checkbox to match strings containing percent encoded characters as per rfc3986.
    • Specific characters (optional): You can add here several specific characters - it can for instance be the underscore char (_), a dash (-), a point (.), etc.
    • Starting With (optional): In combination with other restrictions, this restriction will only match strings starting with this value
    • Ending With (optional): In combination with other restrictions, this restriction will only match strings ending with this value
    • Containing (optional): In combination with other restrictions, this restriction will only match strings containing this value

uuid

The uuid type matches valid uuid-formatted strings.

  • Examples:
    • f6883ff9-f163-43d7-8177-bfa24277fd20

Marker transformations

Introduction

The values that have been matched using markers can be reused in actions. For instance, if you defined a URL trigger with a marker named slug, you can choose to create a Redirection action to a url populated with this marker.

Sometimes, however, your URL format has changed. Imagine, for instance, that your previous URLs used to look like:

  • http://example.org/some_category/some_product.63664.html
  • http://example.org/some_other_category/an_other_product.13719.html
  • http://example.org/an_third_category/a_third_product.871.html

While, after your website redesign, your new URLs have been "cleaned" and now look like:

  • http://example.org/some-category/some-product
  • http://example.org/some-other-category/an-other-product
  • http://example.org/an-third-category/a-third-product

(Yeah, this is much more readable)

You may have defined a URL trigger of the form /<CATEGORY_NAME>/<PRODUCT_NAME>.<PRODUCT_ID>.html, where:

  • <CATEGORY_NAME> is a string marker matching lowercase letters and the _ sign;
  • <PRODUCT_NAME> is a string marker matching lowercase letters and the _ sign;
  • <PRODUCT_ID> is an integer marker.

Just enable a Replace transformation on the <CATEGORY_NAME> and <PRODUCT_NAME> markers, and you will be able to reuse those values by injecting them in a Redirection action of the form:

  • Status code: 302
  • Target URL: /<CATEGORY_NAME>/<PRODUCT_NAME>

Available marker transformation types

redirection.io markers support several transformations:

  • Camelize: Transforms strings of the form some-string into someString (works with dashes and underscores)
  • Dasherize: Generates a dasherized version of the string, where words are separated with dashes, for example hello-world
  • Lowercase: Write all the characters lowercase, for example helloworld
  • Replace: Replaces all the occurrences of a string with another one (for instance, transform st-petersburg to saint-petersburg)
  • Slice: Slices the string from one position (starting at 0) to another (this can be useful, for example, if your marker values have been truncated)
  • Underscorize: Generates a underscorized version of the string, where words are separated with underscores, for example hello_world
  • Uppercase: Write all the characters uppercase, for example HELLO-WORLD

Chain the marker transformations

All these transformations can be chained and are executed sequentially, which means that you can for example successively apply a Replace transform, then a Camelize one:

st-petersburg ➡️ saint-petersburg ➡️ saintPetersburg

Are you up to date on the subject of triggers and markers? Go on with creating an action.

Can't find your answer?