> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# Match a path against redirects

**Published**: 2026-11-30
**Category**: SEO & LLMs

## `GET /redirects/match`

**Match a path against redirects**

Returns the redirect that matches `path`. The site's stored rules are
tried first and always win.

When no stored rule matches, a locale redirect is computed. A leading
default-locale segment is dropped (`/en/pricing` to `/pricing` on an
English-default site). A source-slug URL goes to its translated URL in
that locale. A URL under a locale the site does not enable goes to the
same item in the default locale. A computed redirect is a 301 with
`preserveQueryString: true`: append the visitor's query string to the
target.

Returns 404 `REDIRECT_NOT_FOUND` when nothing matches, and 400 when
`path` is missing.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `path` | query | string | Yes | Source URL path to resolve against the site's active redirect rules. |


### Responses

| Status | Description |
| --- | --- |
| `200` | Successful response |
| `400` | The required `path` query parameter is missing, empty, or not a string. |
| `404` | No safe active stored redirect matches the supplied path, and no locale redirect is synthesized for it. |


> **Notes:** Cache: a match is `public, max-age=0, s-maxage=300`, a miss
> `s-maxage=30`. A blank or oversized path returns an uncached 404.

### SDK

```typescript
import { createClient } from 'lynkow'

const lynkow = createClient({ siteId: process.env.LYNKOW_SITE_ID! })

// In a Next.js middleware
const redirect = await lynkow.paths.matchRedirect(pathname)
if (redirect) {
  return NextResponse.redirect(redirect.target, redirect.statusCode)
}
// No redirect, continue to normal page rendering
```

### Examples

```curl
curl "https://api.lynkow.com/storefront/{siteId}/redirects/match?path=/old-pricing"
```

```javascript
const res = await fetch(`https://api.lynkow.com/storefront/${siteId}/redirects/match?path=/old-pricing`)
if (res.status === 404) return null
const { data } = await res.json()
```

### Response Example

```json
{
  "data": {
    "source": "/old-pricing",
    "target": "https://acme.io/pricing",
    "statusCode": 301,
    "preserveQueryString": true
  }
}
```

---