Config Redirects
Easy · Config
In next.config.ts you can list redirects like { source: "/old-blog", destination: "/blog", permanent: true }. A permanent redirect uses status 308 (browsers and search engines remember it); a temporary one (permanent: false) uses 307.
Write findRedirect(redirects, pathname):
- Find the first redirect whose source is exactly pathname.
- Return { destination, statusCode } with 308 or 307.
- Return null when no redirect matches.
Simplified: real sources can also contain patterns like /blog/:slug; here only exact matches count.
Next: Is the Page Stale?