How to redirect URL in Astro

You can redirect URLs by configuring astro.config.mjs file.

Multiple Static Redirects

To redirect static URLs, list them sequentially as key-value pairs inside the redirects object.

import { defineConfig } from 'astro/config';

export default defineConfig({
	redirects: {
		"/old-about": "/about",
		"/note": "/log"
	}
});

Pattern Matching Redirects

Instead of manually matching all of the URLs, you can redirect an entire directory or parameters using standard Astro routing syntax.

import { defineConfig } from 'astro/config';

export default defineConfig({
	redirects: {
		"/note/[...slug]": "/log/[...slug]"
	}
});