Closed teinett closed 1 year ago
astro
2.2.1
node
npm
mac
firefox, chrome
I migrate old Tumblr blog to AstroJS. I have old links domain.com/post/123, which I would like to save. At the end I will have pages:
I want to have 301 redirect from domain.com/post to domain.com/archive.
What I did:
The code of src/pages/post.astro:
src/pages/post.astro
--- Astro.redirect('/archive'); ---
In the browser I have 2 options:
My config astro.config.mjs:
astro.config.mjs
import { defineConfig } from 'astro/config'; import mdx from "@astrojs/mdx"; import node from "@astrojs/node"; export default defineConfig({ trailingSlash: 'never', integrations: [mdx()], output: 'server', adapter: node({ mode: "standalone" }) });
https://stackblitz.com/edit/github-e5p1e6
You need to return your redirect.
--- return Astro.redirect('/archive'); ---
@matthewp Thanks a lot! It works now!
What version of
astro
are you using?2.2.1
Are you using an SSR adapter? If so, which one?
node
What package manager are you using?
npm
What operating system are you using?
mac
What browser are you using?
firefox, chrome
Describe the Bug
I migrate old Tumblr blog to AstroJS. I have old links domain.com/post/123, which I would like to save. At the end I will have pages:
I want to have 301 redirect from domain.com/post to domain.com/archive.
What I did:
The code of
src/pages/post.astro
:In the browser I have 2 options:
My config
astro.config.mjs
:Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-e5p1e6
Participation