Rules Hub
Code Ruleset
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP1universalStack: Next.js
routingseoredirectsbackwards-compat
Add a redirect when removing or renaming a public route
When you remove a URL path, add a permanent redirect to its replacement so bookmarked/indexed links keep working.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | // /estimater route deleted, old bookmarks now 404 |
Explanation (EN)
Bookmarks and indexed URLs otherwise lead to an avoidable dead end.
Objašnjenje (HR)
Good example
New codets
| 1 | if (tab === 'estimater') { |
| 2 | return permanentRedirect(`/ticker/${fullName}/pinpoint`); |
| 3 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
When retiring a public URL with an equivalent replacement, preserve intended query/path data and test the redirect status and absence of loops.
Exceptions / Tradeoffs (EN)
Use a gone/not-found response when there is no suitable replacement; avoid permanent redirects for temporary moves or private navigation state.