🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Routing••By Komal Nakrani

Fix: Invalid Redirect Destination in Astro

Astro's 'Invalid redirect destination' means a dynamic redirect points at a route that does not exist or lacks its params. Match the route and its params.

#Astro#Errors#Redirects#Dynamic Routes

Astro throws “Invalid redirect destination” when a redirect in astro.config.mjs has a dynamic source like /old/[slug] and its destination either matches no route in your project or is missing one of the source’s parameters. In a static build, Astro generates one redirect page per value of the parameter, so the destination must be a real dynamic route with the same parameters, such as /new/[slug].

Key Takeaways

  • The check applies to redirects whose source contains [param] in static (prerendered) projects.
  • The destination must match an existing route file, written with the same bracket syntax.
  • Every parameter in the source must also appear in the destination route.
  • Astro builds the redirects from the destination route’s getStaticPaths() values.
  • Static redirects (no brackets) and full external URLs are not affected.

The error

There are two versions of the message:

Invalid redirect destination.
The redirect from "/blog/[slug]" to "/articles/[slug]" is invalid. The destination "/articles/[slug]" does not match any existing route in your project.
Invalid redirect destination.
The redirect from "/blog/[year]/[slug]" to "/articles/[slug]" is invalid. The destination route is missing dynamic parameter(s) [year] required by the source route "/blog/[year]/[slug]".
Hint: The destination of a dynamic redirect must include all dynamic parameters from the source route. For example, a redirect from "/old/[slug]" must go to a route that also has a [slug] parameter, like "/new/[slug]".

Why it happens

A static site cannot evaluate /blog/[slug] at request time. To create the redirect pages, Astro looks up the destination route and uses its getStaticPaths() results to know which values of [slug] exist. If the destination string does not match a route, or that route does not have every parameter the source uses, Astro cannot generate the pages.

// astro.config.mjs (fails: no such route)
import { defineConfig } from 'astro/config';

export default defineConfig({
  redirects: {
    '/blog/[slug]': '/articles/[slug]',
  },
});

This fails if your posts are rendered by src/pages/posts/[slug].astro, or by src/pages/articles/[...slug].astro, because the route string differs.

Fix: match the real route

Write the destination exactly as the route file defines it:

Route file Destination string
src/pages/articles/[slug].astro /articles/[slug]
src/pages/articles/[...slug].astro /articles/[...slug]
src/pages/[lang]/articles/[slug].astro /[lang]/articles/[slug]
// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  redirects: {
    '/blog/[...slug]': '/articles/[...slug]',
  },
});

The source and destination parameter types should match too: redirect a rest parameter to a rest parameter.

Fix: drop a parameter

If the new URLs remove a segment (for example the year), a dynamic redirect cannot express that. List the old URLs explicitly instead, generated from your content:

// astro.config.mjs
import { defineConfig } from 'astro/config';
import fs from 'node:fs';

const posts = JSON.parse(fs.readFileSync('./redirects.json', 'utf8'));
// [{ "from": "/blog/2025/launch/", "to": "/articles/launch/" }, ...]

export default defineConfig({
  redirects: Object.fromEntries(posts.map(({ from, to }) => [from, to])),
});

For many redirects, host-level rules (_redirects on Netlify and Cloudflare Pages) are lighter. Our Astro redirects tip compares the approaches, the routing guide explains route strings, and the pages docs cover file routes. The official redirects reference lists the rules. If you are migrating a site onto one of our Astro themes, the site migration SEO checklist covers redirects end to end.

FAQ

Can Astro redirect dynamic routes?

Yes. Use brackets in both the source and destination, like '/old/[slug]': '/new/[slug]'. The destination must be an existing dynamic route with the same parameters.

Why does my Astro redirect say no matching route?

The destination string does not match any route file. Check spelling, the rest parameter syntax ([...slug]), and any locale or base segments.

How do I redirect URLs that change structure?

List each old URL as a static redirect, generated from your content or a JSON file, or use your host’s redirect rules.