- Fastly Status
Last updated July 28, 2017
If you are having problems using conditions, here are some common mistakes to look for:
- Don't use the wrong case. Varnish regular expressions are case sensitive.
- Don't escape forward slashes. Forward slashes don't need to be escaped in Varnish regular expressions.
- Don't put the
if ()statement in the Apply if field of the condition window. The actual if statement is implied. You only need to type an evaluated expression. For example:
req.url ~ "^/special/". Most problems with conditions occur in the Apply if parameter because it uses logical expressions to represent actual VCL variables that specify when a condition should be applied to a configuration object.
- Don't use the
!~(inverse regex match) to build regular expressions that exclude particular URLs. For example, if you want to apply something to all URLs except those that start with
/admin, the condition for this is
req.url !~ "^/admin"and is entered in the Apply If field. An alternative to this expression would be
!(req.url ~ "^/admin").
Our cheatsheet provides additional examples of using VCL with regular expressions.Back to Top