---
title: table.contains
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/table/table-contains
---

```
BOOL table.contains(ID id, STRING key)
```

**Available in:** all subroutines

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

## Example

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

```vcl
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;
}
```
