Triggers and markers reference
Triggers define the way redirection.io agents will match incoming requests before performing an action.
In a Rule, the Triggers are the conditions that incoming HTTP requests must match in order the rule to be applied. For one given incoming HTTP requests, several rules can be matched, if all of their triggers are matched.
redirection.io implements different types of Triggers:
- the URL of the request
- the presence, absence or value of a HTTP request header
- the HTTP method of the request
- the backend response status code
If you need another type of trigger, feel free to contact us, we welcome every good idea!
The URL trigger¶
The URL trigger is 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
The source URL trigger is required for all the Rules, in the first step of the Rule creation form:
The URL trigger can use markers, which are a powerful way to match several URLs at once, based on patterns. For example, a Rule can be created to redirect all the URLs of the form
/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. Read the chapter about markers to understand how they work.
If you want a Rule to be executed for every request to your website, please use a marker of the type
anything. You can combine this very permissive URL trigger with more restrictive triggers of other types:
The Header trigger¶
The Header trigger allows to select request based on the presence, the absence or the value of a HTTP header in the request. There are manu use cases for this header: redirecting the user based on his preferred language (
Accept-Language header), run a specific action for a particular
The above example Rule will be triggered for every request arriving on your website with an
Accept-Language request header starting with
fr- (so, for example,
fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,de;q=0.6, but not
The Method trigger¶
The Method trigger filters requests based on the HTTP method used for performing the request. You can select one or more HTTP method, and the Rule will be triggered only if the HTTP method used for the request matched one of the selected methods:
The Backend Response Status Code trigger¶
The Backend Response Status Code trigger allows to restrict triggering a Rule based on the Status Code generated by your backend application. When a rule uses the backend response status code trigger, it will first let the request go by to your backend application, and it will inspect the response HTTP status code that your application generated.
This is useful, for example, if you want to execute a specific action when a given Status Code is going to be sent back to the user.
Creating a marker¶
As explained above, markers are useful to have one rule apply to several URLs at once, without the need to create several rules. Defining a marker is quite simple:
- click on the "Add marker" button. A modal window appears, with three tabs.
- Specify 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;
The "Restrictions" tab allows to define the marker type and characteristics. You can for instance define
stringmarkers, containing only uppercase letters and starting with the
- "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
Hovering on the marker displays the details of the marker, which is useful to understand what this markers does:
redirection.io supports a quite large variety of URL markers:
date type stands for a full-date, as per rfc3339.
datetime type stands for a date-time, as per rfc3339.
enum type allows to list exact accepted values.
it can be multiple words
- Values (required): Just type the character or word that the marker must match, and press "enter".
integer type matches positive integer values (aka. natural numbers).
Minimum (optional): You may define a minimal value for the marker to match. For instance, if you type
404in the "minimum" field, the values
1234will be match, but not
403. This bound is inclusive (which means, with the previous example, that
404will be matched).
Maximum (optional): You may define a maximal value for the marker to match. For instance, if you type
404in the "maximum" field, the values
403will match, but not
1234. This bound is inclusive (which means, with the previous example, that
404will be matched).
- Minimum (optional): You may define a minimal value for the marker to match. For instance, if you type
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.
- Regex (required): Type here the regular expression that you want to use during the matching
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.
- 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
digits (optional): Check this checkbox to match strings containing digits (
- 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 (
- 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 type matches valid uuid-formatted strings.
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:
While, after your website redesign, your new URLs have been "cleaned" and now look like:
(Yeah, this is much more readable)
You may have defined a URL trigger of the form
stringmarker matching lowercase letters and the
stringmarker matching lowercase letters and the
Just enable a
Replace transformation on the
<PRODUCT_NAME> markers, and you will be able to reuse those values by injecting them in a Redirection action of the form:
- Status code:
- Target URL:
Available marker transformation types¶
redirection.io markers support several transformations:
Camelize: Transforms strings of the form
someString(works with dashes and underscores)
Dasherize: Generates a dasherized version of the string, where words are separated with dashes, for example
Lowercase: Write all the characters lowercase, for example
Replace: Replaces all the occurrences of a string with another one (for instance, transform
- 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
Uppercase: Write all the characters uppercase, for example
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
It may happen that many rules in your ruleset use the same marker. For example, imagine that you need to define a rule that contains a
country parameter, whose value can be
us. You would usually do this using an enum marker type with these values.
If, however, you need to define many rules containing the same marker, it can become a bit repetitive to re-create this marker in all these rules. This is where marker templates come into play, allowing you to define markers that can be reused in multiple rules without the need to re-define them each time.
To learn more about marker templates, see the project configuration section of our documentation.
Are you up-to-date with triggers and markers? Go on with creating an action.