Skip to content

Match Expressions

A match expression is a boolean expression that determines whether a rule applies to an incoming request. It has access to all variables and functions.

If a rule has no match expression it matches every request — useful as a catch-all at the end of the rule list.

Syntax

Expressions use standard C# expression syntax via DynamicExpresso:

  • String literals: "value" (double quotes)
  • Boolean operators: &&, ||, !
  • Comparison: ==, !=, <, >, <=, >=
  • String indexer: QueryParams["key"], Headers["name"]

Examples

Match a specific host:

Host == "old.example.com"

Match a path prefix:

StartsWith(Path, "/legacy/")

Match by country:

Geo.Country == "NL"

Match a numeric path segment in a range:

IntBetween(Segment(Path, 1), 1, 9999)

Match requests from a specific country that are not returning visitors:

Geo.Country == "DE" && !IsReturningVisitor

Match via map — only redirect if the key exists in the map:

Map("products", Segment(Path, 1)) != ""

Match a query parameter:

QueryParams["lang"] == "nl"

Match using regex:

Matches(Path, @"^/product/\d+$")

Catch-all (no expression set): Leave the match expression blank. The rule always matches.

Evaluation behaviour

  • If the expression throws (syntax error, type mismatch), the rule is skipped and the error is recorded. Subsequent rules are still evaluated.
  • Dictionary access (QueryParams["missing"]) returns "" for missing keys — it does not throw.
  • Geo values are "" (empty string) when GeoIP cannot resolve the IP. Rules that compare Geo.Country == "NL" will simply not match such requests.