Available inall subroutines.

Returns true if the key key has an entry in the table id.


Here's one way of implementing a simple redirect mechanism, conditional on presence in a table of URLs:

table redirects {
"/a": "/xyz",
"/b": "/abc",
sub vcl_recv {
if (table.contains(redirects, req.url.path)) {
error 800 "redirect";
sub vcl_deliver {
set resp.http.location = table.lookup(redirects, req.url.path)
+ if(req.url.qs == "", "", "?" + req.url.qs);
set resp.status = 301;

Try it out

table.contains is used in the following code examples. Examples apply VCL to real-world use cases and can be deployed as they are, or adapted for your own service. See the full list of code examples for more inspiration.

Click RUN on a sample below to provision a Fastly service, execute the code on Fastly, and see how the function behaves.

Redirect old URLs at the edge

Use a dictionary of URL mappings to serve your redirects at lightning speed.