table.lookup_regex
Available inall subroutines.
Looks up the key key
in the table id
. When the key is present, its
associated value will be returned. When the key is absent, an
unsatisfiable regex
will be returned.
Example
# Here we allow a different set of extensions per-path in the url.# For example:# /articles/abc.png - wrong extension for the dirname# /images/abc.png - this extension is allowed for /imagestable t REGEX { "/images": "^(?:jpe?g|png)$", "/articles": "^md$",}
sub vcl_recv { declare local var.re REGEX; set var.re = table.lookup_regex(t, req.url.dirname); if (req.url.ext !~ var.re) { error 403; # unexpected file extension }
error 200;}