# Create your first redirect

> Redirect every request for a retired name to your main domain at the edge, keeping the path and the query string.

In this example `old.example.com` is retired and every request should go to `https://example.com` with the same path and query: `old.example.com/a/b?x=1` → `https://example.com/a/b?x=1`.

1. **Make sure the name is proxied.** The edge only answers names that have a proxied DNS record (A, AAAA or CNAME with the proxy on). If every path redirects, the record's content is never used, so it can point to the same origin as the apex.
2. **Add the rule.**

**Dashboard**

   Open the domain and go to **Rules → Redirects** → **Add redirect**. Set **Name** to `old.example.com`, **Path prefix** to `/`, **Destination URL** to `https://example.com`, **Status** to `301 · Permanent`, keep **Keep the rest of the path** and **Keep the query string** on, and click **Apply**. Then save the change with a reason.
**CLI**

   ```sh
   openwaf-cloud ctl zones set example.com \
     redirects:='[{"host":"old.example.com","target":"https://example.com"}]' \
     --reason "Retire old.example.com"
   ```
   `redirects` replaces the whole list: include the rules you already have (`zones show example.com` lists them).
**API**

   ```sh
   curl -sS -X PATCH "https://dash.openwaf.dev/v1/orgs/$ORG/zones/example.com/edge" \
     -H "Authorization: Bearer $OPENWAF_TOKEN" \
     -H "X-Change-Reason: Retire old.example.com" \
     -H "Content-Type: application/json" \
     -d '{"redirects": [{"host": "old.example.com", "target": "https://example.com"}]}'
   ```
**MCP**

   `update_settings` with `{"zone": "example.com", "settings": {"redirects": [{"host": "old.example.com", "target": "https://example.com"}]}, "reason": "…"}`. Simulate, then confirm.

3. **Test it.**

   ```sh
   curl -sI https://old.example.com/a/b?x=1
   ```

   ```http
   HTTP/2 301
   location: https://example.com/a/b?x=1
   ```


Next: [how redirect rules match](https://developers.openwaf.dev/rules/redirects/), and the [fields](https://developers.openwaf.dev/rules/redirect-reference/) you can set.
