# Next.js redirects

> Configure redirects in next.config.js, choose 307 or 308 correctly, preserve path parameters, and test the deployed route behavior.

Canonical: https://scaplet.com/seo/nextjs/redirects

Guide Next.js Next.js · Routing

Configure redirects in next.config.js, choose 307 or 308 correctly, preserve path parameters, and test the deployed route behavior.

5 min

read

6

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

Use `redirects()` in `next.config.js` for a fixed set of path changes that should run before filesystem routes. Set `permanent: true` for a lasting move (Next.js returns 308) and `false` for a temporary one (307). For request-dependent decisions, use a route handler or Proxy instead; then test both the HTTP response and client navigation in the router you use.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fredirects%20(%22Next.js%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fredirects%20(%22Next.js%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fredirects%20(%22Next.js%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%2Fredirects%20(%22Next.js%20redirects%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 5 minutes.

1. [Use config redirects for known path changes 01](#use-config-redirects-for-known-path-changes)
2. [Match dynamic routes safely 02](#match-dynamic-routes-safely)
3. [Pick the right Next.js layer 03](#pick-the-right-next-js-layer)
4. [Scale a large redirect map without slowing every request 04](#scale-a-large-redirect-map-without-slowing-every-request)
5. [Test the deployed behavior 05](#test-the-deployed-behavior)

_01_Check it

## Use config redirects for known path changes

Put stable path mappings in the `redirects` function of the root Next.js config file (`next.config.js`, `.mjs` or `.ts`). Next.js evaluates these rules before the filesystem, so a rule can take precedence over a page or a file under `public`. Return an array of objects with `source`, `destination`, and `permanent`; keep the mapping small enough that a teammate can review each destination.

Next.js maps `permanent: true` to [HTTP 308](/errors/http/308) and `false` to [HTTP 307](/errors/http/307). Its docs say 308 tells clients and search engines to cache the redirect forever, while 307 is temporary and not cached. Google treats 301 and 308 as permanent signals and 302, 303, and 307 as temporary signals. Choose based on whether you intend the source URL to be replaced in search, not because one status number looks more SEO-friendly. See Google's [redirect guidance](/glossary/301-redirect) and [HTTP status code reference](/glossary/http-status-codes).

Permanent path move

```
module.exports = { async redirects() { return [{ source: '/docs/old-guide', destination: '/docs/new-guide', permanent: true }] }, }
```

_02_Checklist

## Match dynamic routes safely

Use named path segments when a section moves intact. A catch-all parameter can carry the remainder of a path, and Next.js passes request query values through to the destination. Include the slash before `:` in path parameters; the docs warn that omitting it makes the value literal and can create an accidental loop.

First_2_
Use a one-to-one mapping when a page has a clear replacement. A product docs URL should land on its replacement, not the homepage.

Map supported locale paths deliberately. The App Router docs say locale redirects in config are hardcoded paths; use dynamic route segments and Proxy for per-request locale decisions.

Next_1_
When `basePath` is configured, Next.js applies it to matching config redirects by default. Set `basePath: false` only when a route intentionally sits outside that prefix.

Then_1_
Keep request-dependent logic out of a static mapping. Use a request-time mechanism documented for the router and runtime you deploy.

Move a documentation section

```
{ source: '/guides/:path*', destination: '/learn/:path*', permanent: true }
```

_03_Choose by what the redirect needs to know

## Pick the right Next.js layer

Requirement

### Fixed old path maps to one new path

Use

`redirects()` in config

Reason

Central mapping runs before filesystem routes

Requirement

### Destination depends on the incoming request

Use

Route Handler or Proxy

Reason

These can make a request-time decision

Requirement

### A Server Component must redirect while [rendering](/glossary/rendering)

Use

`redirect` or `permanentRedirect`

Reason

Application code controls the response

Requirement

### Serve another route while keeping the original URL

Use

Rewrite

Reason

A redirect changes the browser URL

One router-specific gotcha matters during migrations: Next.js documents that config redirects in the Pages Router do not apply to client-side routing calls such as `Link` or `router.push` unless Proxy is present and matches the path. A direct browser request may work while an in-app link follows a different path. Test both entry points before shipping a broad migration.

_04_Checklist

## Scale a large redirect map without slowing every request

Next.js suggests a custom Proxy solution for 1,000 or more redirects. Proxy is the Next.js 16 name for the file convention earlier versions call Middleware. The deployment platform can impose a lower config limit: the current Next.js guide gives Vercel as an example with a 1,024-redirect limit. Check your host before choosing where the mapping lives; this number is not a universal Next.js limit.

1. 01 Keep the redirect data separate from application code if editors or migration owners need to update it without rebuilding the app.
2. 02 Validate map entries before deployment: source paths should be unique, destinations should resolve, and no path should redirect back to itself or create a cycle.
3. 03 Measure request latency and failures on your actual hosting platform. A lookup strategy that is fast locally may behave differently at the edge or when it reads a remote store.

For a large migration map, the Next.js guide shows storing paths and destinations in a JSON file or key-value store and looking up the incoming pathname in Proxy. Avoid reading a large mapping on every request without measuring it. The guide suggests a fast-read data store or a Bloom filter to quickly reject paths that are not in the map before loading full redirect data.

_05_How it works

## Test the deployed behavior

**Avoid a generic migration destination**Google warns that sending many unrelated old pages to one homepage can confuse users and may be treated as a soft 404. Map each old URL to a close replacement, or let it return a real 404 or 410 when no equivalent page exists.

Keep permanent rules long enough for visitors and crawlers to reach the replacement. Google recommends keeping site-move redirects as long as possible, generally at least one year. Before deploying a large mapping, review it for duplicate sources, cycles, and destinations that return another redirect. On Remix, see [Remix redirects](/seo/remix/redirects).

1. 01

### Check an old URL over HTTP

Run `curl -sS -D - -o /dev/null https://example.com/old-path`. Check the returned status and `Location` header. Repeat with a [trailing slash](/glossary/trailing-slash) and [query string](/glossary/url-parameters) if those variants receive traffic.
2. 02

### Follow the chain

Run `curl -sS -L -o /dev/null -w '%{http_code} %{url_effective} %{num_redirects}\n' https://example.com/old-path`. Confirm the final page is intended and remove intermediate hops by targeting the final URL.
3. 03

### Check the destination

Inspect its [canonical URL](/glossary/canonical-url), robots directive, and content. Update [internal links](/glossary/internal-links) and sitemap entries to point straight to the destination. Google also says to make sure the canonical annotations on a moved site use the new URLs.
4. 04

### Inspect representative URLs

For a migration, inspect mapped source and destination URLs in [Search Console](/glossary/google-search-console) after deployment. Google recommends testing redirects and submitting the new sitemap; temporary ranking movement can happen while URLs are recrawled.

Questions

## Asked a lot.

3 questions people ask next, answered from the sources on this page.

_01_ Does `permanent: true` return a 301 in Next.js?

No. The Next.js config maps `permanent: true` to HTTP 308 and `false` to HTTP 307. Google treats 308 as a permanent redirect signal.

_02_ Where do I add redirects in Next.js?

For fixed mappings, add a `redirects()` function (it can be async) to the root Next.js config file, returning objects with `source`, `destination`, and `permanent`. Use a request-time layer when the result depends on the request.

_03_ Why does my redirect work on refresh but not on a Link click?

Next.js says config redirects do not apply to Pages Router client-side routing calls unless Proxy is present and matches the path. Test direct requests and in-app navigation separately.

Sources · 6

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- nextjs.org
- google.com

1. 01 [redirects | Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects) nextjs.org · checked 2026-10-24
2. 02 [Redirecting | Next.js](https://nextjs.org/docs/app/guides/redirecting) nextjs.org · checked 2026-10-24
3. 03 [rewrites | Next.js](https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites) nextjs.org · checked 2026-10-24
4. 04 [Proxy | Next.js](https://nextjs.org/docs/app/api-reference/file-conventions/proxy) nextjs.org · checked 2026-10-24
5. 05 [Redirects and Google Search | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/301-redirects) developers.google.com · checked 2026-10-24
6. 06 [Site Moves and Migrations | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/site-move-with-url-changes) developers.google.com · checked 2026-10-24

## Keep learning

[All platform guides](/seo)

[Learn Next.js SEO Frameworks](/seo/nextjs) [Related HTTP status codes Crawling and indexing](/glossary/http-status-codes) [Read next Next.js 404 page Frameworks](/seo/nextjs/404) [Do Run a free site audit Free, about two minutes](/site-audit)

More in Next.js SEO
[Next.js 404 page](/seo/nextjs/404) [Next.js AI crawlers](/seo/nextjs/ai-crawlers) [Next.js canonical tags](/seo/nextjs/canonical-tags) [Next.js Google Analytics](/seo/nextjs/google-analytics) [Next.js image SEO](/seo/nextjs/image-seo) [Next.js lazy loading](/seo/nextjs/lazy-loading) [Next.js noindex](/seo/nextjs/noindex) [Next.js redirects](/seo/nextjs/redirects) [Next.js robots.txt](/seo/nextjs/robots-txt) [Next.js structured data](/seo/nextjs/structured-data) [Next.js title and meta description](/seo/nextjs/title-and-meta) [Next.js XML sitemap](/seo/nextjs/xml-sitemap)

Terms on this page
[301 redirect](/glossary/301-redirect) [HTTP status codes](/glossary/http-status-codes) [Rendering](/glossary/rendering) [Trailing slash in URLs](/glossary/trailing-slash) [URL parameters](/glossary/url-parameters) [Canonical URL](/glossary/canonical-url) [Internal links](/glossary/internal-links) [Google Search Console](/glossary/google-search-console)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
