> For the complete documentation index, see [llms.txt](https://greymatter.gitbook.io/grey-matter-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://greymatter.gitbook.io/grey-matter-documentation/usage/fabric/api/domain/redirect.md).

# redirect

## Summary

Redirects specify how URLs may need to be rewritten. Each Redirect has a name, a regex that matches the requested URL, a to indicating how the url should be rewritten, and a flag to indicate how the redirect will be handled by the proxying layer.

### Example object

```javascript
{
  "name": "force-https",
  "from": "(.*)",
  "to": "https://$1",
  "redirect_type": "permanent"
}
```

### Fields

#### `name`

Common name for this redirect, e.g. "force-https".

#### `from`

Regex pattern to match against incoming request URLs. Capture groups set here can be used in the [to](/grey-matter-documentation/usage/fabric/api/domain/redirect.md#to) field.

#### `to`

New URL of the redirect. Can be direct string ("<https://localhost:443>) or reference capture groups from the [from](/grey-matter-documentation/usage/fabric/api/domain/redirect.md#from) field ("[https://localhost:$1](https://localhost/:$1)").

#### `redirect_type`

One of "permanent" or "temporary". Selection "permanent" will set the response code to 301, "temporary" will be 302.

#### `header_constraints`

Array of [Header Constraints](/grey-matter-documentation/usage/fabric/api/domain/header_constraint.md) that must match for the redirect to take effect.
