.htaccess - What is the best way to redirect (301) many articles on Gatsby JS?
问题描述
I'm migrating a Wordpress blog to Gatsby.
I need to create redirections (http 301) from this kind of url :
https://myblog.com/my-article-slug
To this kind of url
https://myblog.com/blog/my-article-slug
I found two plugins that could help me to do it but it seems tedious to use them since I have 50+ articles.
- https://www.gatsbyjs.com/plugins/gatsby-plugin-htaccess/
- https://www.gatsbyjs.com/plugins/gatsby-redirect-from/
FYI :
This website has internal pages like /contact
or /terms
so I can't just redirect anything from /slug
to /blog/slug
.
Do you have any better way to do this in mind ?
解决方案
If you are using Netlify you can try using a _redirects file : https://docs.netlify.com/routing/redirects/