How to create 301 redirects for a react app with page-router

We already have /* /index.html 200 for the app to work, but we also need to create a number of 301 redirects to certain routes for the page-router. Adding them in the _redirects file doesn’t seem to work, even though Netlify says they have been processed without errors:


/my-old-url /my-new-url 301
/* /index.html 200

Any help appreciated!

Hey @chrisrhm, I’m not sure what you mean by using Netlify _redirects with page-router. if you’re using a client-side routing library (which it sounds like what page-router is, but correct me if I’m wrong), you’ll implement your routes in your Javascript code, as opposed to in your _redirects file. So the first rule you mentioned that redirects everything to your index.html should be all you need on the Netlify side.

For example, if you were using the React-based static site generator Gatsby, you would use Gatsby’s syntax shown here:

Hope that helps! If you have follow-up questions, we’ll probably ask you for your Netlify URL so we can dig in further :slight_smile: