Skip to content

feat: redirects for the front end (0.5) - #12

Merged
ogorzalka merged 1 commit into
mainfrom
feat/0.5-redirects
Nov 24, 2026
Merged

ogorzalka merged 1 commit into
mainfrom
feat/0.5-redirects

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Second slice of 0.5. A front end has no memory of a renamed or moved page: the redirects now come from WordPress.

  • Rules you manage: wp headless redirect add|remove|list|test, exact paths or patterns (anchored on the whole path, groups in the destination), 410 for a page that is gone. A rule is validated when made: path, destination (a path or an absolute http(s) URL, never //host or javascript:), status, a pattern that compiles, no loop.
  • Old slugs: the _wp_old_slug WordPress keeps for renamed posts, each to the current address (published posts only, kept five minutes, dropped on save).
  • GET /headless/v1/redirects and /redirects/resolve?path=/old/ (a 200 with null when nowhere, so a CDN keeps it).
  • The rules you write win over the old slugs; an exact rule wins over a pattern.
  • Unit and integration tests (real option, real old slugs, real REST).

- Redirect and RedirectRules: validated rules (path, destination, status, pattern, loop), exact before pattern, first source wins
- OptionRedirectStore (managed with wp headless redirect add|remove|list|test) and OldSlugRedirects (the earlier addresses WordPress keeps for renamed posts, each to the current one)
- GET /wp-json/headless/v1/redirects and /redirects/resolve?path= (a 200 either way, cacheable)
@ogorzalka ogorzalka added the api-change The public surface (hooks, config keys, commands) changes label Nov 24, 2026
@ogorzalka
ogorzalka merged commit 501eacd into main Nov 24, 2026
11 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change The public surface (hooks, config keys, commands) changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant