Path Matching—Contains Versus Pattern Match

When configuring content protection settings for paths, you can apply a policy to your paths using one of two match types: Contains or Pattern Match.


Contains lets you create a policy for all paths having a known character string. For example, if you configure a path policy for ​/api​ and set the Match Type to Contains, Distil then applies the policy to any path containing that string, such as /api​​, /api/v1, and /api/example.

Another example is an ecommerce site that wants to protect all of its products. Configuring a policy for the /products/ path, followed by setting the Match Type to Contains then applies this policy to /products/electronics/, /products/electronics/tvs, /sale/products/garden, and any other path that includes the /products/ string.

Pattern Match

Pattern Match lets you create a policy for all paths containing both defined and undefined character strings. Distil uses Lua patterns in handling undefined character strings, which allow character classes to represent a set of characters. For example, the character class . (a single dot) is a wildcard that represents all characters. Similarly, %a represents all letters, while %d represents all digits.

If you configure a path policy for /product/[0-9]+ and set the Match Type to Pattern Match, Distil applies it to any path containing your product ID numbers. This includes /product/1, /product/200, and /product/230987, but not /products/tvs, /products/all.

Pattern Match Priorities
The Distil platform does not prioritize one match type (Contains or Pattern Match) over the other, but you can set policy priorities in the Distil Portal.

Additionally, priority is governed by path match length. For example, if content protection settings are configured to pattern-match both paths /head and /heade, then when a /headers.php file request is made, Distil applies the latter policy because it is one character longer than the former. If the match length is the same, the highest Priority value wins out.

Additional Resources
Learn more about Lua and Lua patterns using the linked resources below:

  • About Lua and the Lua patterns manual at
  • Lua manual and patterns tutorial at
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request