# pier routes

> Site routing rules

URL: https://pier.run/docs/cli/reference/routes

```bash
pier routes <command>
```

Site routing rules.

## Subcommands

### pier routes ls

```bash
pier routes ls [<site>]
```

List a site's routing rules.

| Argument | Required | Description                    |
| -------- | -------- | ------------------------------ |
| `<site>` | no       | Site ref (name or name/target) |

### pier routes add

```bash
pier routes add [<site>] [<route-type>] [flags]
```

Add a routing rule (redirect, rewrite, header).

| Argument       | Required | Description                              |
| -------------- | -------- | ---------------------------------------- |
| `<site>`       | no       | Site (name or name/target); omit to pick |
| `<route-type>` | no       | Route type (redirect, rewrite, header)   |

| Flag            | Value         | Default | Description                                                         |
| --------------- | ------------- | ------- | ------------------------------------------------------------------- |
| `-y`, `--yes`   |               |         | Skip confirmation prompt                                            |
| `--stage`       |               |         | Write the change to pier.yaml only — apply later with 'pier deploy' |
| `--source`      | `STRING`      |         | Source path pattern                                                 |
| `--destination` | `STRING`      |         | Destination path or URL                                             |
| `--status`      | `308`         | `308`   | Redirect status code (301/302/307/308)                              |
| `--path`        | `STRING`      |         | Header rule path pattern                                            |
| `--headers`     | `HEADERS,...` |         | Header key=value pairs                                              |

### pier routes rm

```bash
pier routes rm [<site>] [<route-type>] [flags]
```

Remove a routing rule.

| Argument       | Required | Description                              |
| -------------- | -------- | ---------------------------------------- |
| `<site>`       | no       | Site (name or name/target); omit to pick |
| `<route-type>` | no       | Route type (redirect, rewrite, header)   |

| Flag          | Value    | Default | Description                                                         |
| ------------- | -------- | ------- | ------------------------------------------------------------------- |
| `-y`, `--yes` |          |         | Skip confirmation prompt                                            |
| `--stage`     |          |         | Write the change to pier.yaml only — apply later with 'pier deploy' |
| `--source`    | `STRING` |         | Source/path pattern to remove                                       |
| `--path`      | `STRING` |         | Header rule path to remove                                          |

### pier routes fallback

```bash
pier routes fallback [<site>] [flags]
```

Configure the SPA fallback.

| Argument | Required | Description                              |
| -------- | -------- | ---------------------------------------- |
| `<site>` | no       | Site (name or name/target); omit to pick |

| Flag          | Value | Default | Description              |
| ------------- | ----- | ------- | ------------------------ |
| `-y`, `--yes` |       |         | Skip confirmation prompt |

[Global flags](/docs/cli/reference#global-flags) apply to every command.
