Skip to content

Commit 6ec93a5

Browse files
feat: document external redirects (#10704)
Co-authored-by: Sarah Rainsberger <[email protected]> Co-authored-by: sarahrainsberger <[email protected]>
1 parent 56990e2 commit 6ec93a5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/content/docs/en/guides/routing.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,17 @@ You can define rules to [redirect users to permanently-moved pages](#configured-
250250

251251
<p><Since v="2.9.0" /></p>
252252

253-
You can specify a mapping of permanent redirects in your Astro config with the `redirects` value. For most redirects, this is a mapping of an old route to the new route:
253+
You can specify a mapping of permanent redirects in your Astro config with the [`redirects`](/en/reference/configuration-reference/#redirects) value.
254+
255+
For internal redirects, this is a mapping of an old route path to the new route. As of Astro v5.2.0, it is also possible to redirect to external URLs that start with `https` or `https` and [can be parsed](https://developer.mozilla.org/en-US/docs/Web/API/URL/canParse_static):
254256

255257
```js title="astro.config.mjs" {4-6}
256258
import { defineConfig } from 'astro/config';
257259

258260
export default defineConfig({
259261
redirects: {
260-
'/old-page': '/new-page'
262+
'/old-page': '/new-page',
263+
'/blog': "https://example.com/blog"
261264
}
262265
});
263266
```
@@ -282,6 +285,10 @@ export default defineConfig({
282285
'/old-page': {
283286
status: 302,
284287
destination: '/new-page'
288+
},
289+
'/news': {
290+
status: 302,
291+
destination: "https://example.com/news"
285292
}
286293
}
287294
});

0 commit comments

Comments
 (0)