> Index of every page on this site: [llms.txt](https://docs.a-line.cloud/llms.txt)

# Redirects

> Send a domain, or some of its paths, to another URL without running an app.

A redirect answers visitors of a domain with a `Location` header, right at
the edge. It needs no app, no container and no build. Use one to move an old
domain to a new one, to send `www` to the apex, or to move a few paths
somewhere else.

A redirect belongs to a project and is served by the project's cluster. It
owns its domains. A domain either redirects or routes to an app or site,
never both.

## Forward a domain

A **forward** sends every request on its domains to one URL. With
**Keep path** and **Keep query** on, `https://old.example.com/pricing?plan=pro`
goes to `https://example.net/pricing?plan=pro`. With both off, every request
goes to the target as written.

## Path rules

For more control, a redirect holds an ordered list of **rules** instead of
a forward. Each rule has a match (`when`) and a target (`then`):

- `host`: one of the redirect's domains. Leave it out to match all of them.
- `path`, one of:
  - `exact`: this path only.
  - `prefix`: this path and everything below it. `/docs` matches `/docs/a`
    but never `/docsearch`.
  - `glob`: `:name` matches one path segment, and a trailing `*` matches
    the rest.
- `to`: the target URL. Its path and query can use `${path}` (the request
  path), `${splat}` (what `*` matched) and `${name}` (what `:name` matched).

Rules run top to bottom, and the first enabled rule that matches answers.
Put specific rules first and a catch-all (no `path`) last. For example, to
move a blog and send everything else to the home page:

1. `/blog/*` goes to `https://example.net/guides/${splat}/`
2. everything else goes to `https://example.net`

Matching is case-sensitive. A request that no rule matches gets a `404`.

## Status codes

Pick **Permanent (301)** or **Temporary (302)**. Browsers and search
engines cache a permanent redirect, so start with temporary while you test.

`GET` and `HEAD` requests get the status you picked. Every other method gets
its method-keeping twin: `308` for permanent and `307` for temporary. A
`POST` to an API that moved therefore stays a `POST`.

## Order at request time

When a request comes in, these steps run in this order:

1. **Redirects** run first, at the edge.
2. **HTTP settings** of the app or site, such as the `www` redirect and HSTS.
3. A static site's own `_redirects` and `_headers` files.

A redirect therefore wins over a static site's `_redirects`.

## Limits

| What | Limit |
| --- | --- |
| Rules per redirect | 20 |
| Redirects per project | 25 |
| Forwarded domains per organization | 250 |
| Target URL length | 2048 characters |

A target must be a public `http` or `https` URL. It may not point at a
private address or at the platform's own domains. Redirects that send
visitors round in a loop are refused when you save, and the error lists the
URLs of the loop.

## Domains and DNS

Each domain of a redirect must be covered by a
[verified domain](/concepts/domains#organization-domains) of your
organization, just like an app domain. Point the domain at the project's
cluster with the same `A`/`AAAA` or `CNAME` records an
[app domain](/concepts/domains#app-domains) uses. A certificate is then
issued automatically. Until it is issued, `http://` already redirects, but
`https://` shows a certificate error.

The project needs a cluster before it can hold a redirect.

## Manage redirects

- **Console:** in the project designer, add a **Redirect**, choose its
  domains, then either forward them to a URL or add rules.
- **Infrastructure as code:** one file per redirect, `redirects/<name>.yaml`.
  See [Redirects in IaC](/iac/redirects).
