---
title: "Move redirects into next.config redirects()"
description: "next.config redirects run before rendering and return 308 for permanent rules, so old URLs keep their signals without shipping JavaScript. Move server-side redirect maps into redirects(), mark permanent changes permanent, scope rules with has and missing, and keep temporary campaigns separate. Verify with curl that each old path returns one hop and the expected status."
url: "https://seo-mcp.io/t/move-redirects-into-next-config-redirects"
---

# Move redirects into next.config redirects()

next.config redirects run before rendering and return 308 for permanent rules, so old URLs keep their signals without shipping JavaScript. Move server-side redirect maps into redirects(), mark permanent changes permanent, scope rules with has and missing, and keep temporary campaigns separate. Verify with curl that each old path returns one hop and the expected status.

## Prerequisites

- Next.js project with a deployed next.config file
- A list of old paths and their canonical destinations

## Steps

1. **Collect the current redirect map** — List every old URL that still receives traffic or links, with its destination, from the CMS, middleware, server config and analytics landing pages.
   Check: The list has one destination per source path and marks which moves are permanent.
2. **Declare rules in next.config** — Add an async redirects() export returning source, destination and permanent for each mapping. Use :path parameters for pattern rules and has or missing for scoped cases.
   Check: next.config contains the redirects export and the build completes without a redirect error.
3. **Remove overlapping handlers** — Delete duplicate rules from middleware or hosting config so one path is handled once. Keep client-side navigation redirects out of the crawler path.
   Check: Only one layer defines each source path in the repository.
4. **Test status and hop count** — After deploy, request each old path with curl -sI and follow the chain. Confirm a single hop to a 200 destination with the expected 308 or 307 status.
   Check: curl -sI your production domain/<old-path> shows one location header and the destination returns 200.

## Source

@seo-mcp on 2026-10-19: https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects

Canonical: https://seo-mcp.io/t/move-redirects-into-next-config-redirects
