home ~ projects ~ socials

How-To Setup Redirects For A Next.js Site On Netlify

To use a _redirects file, set one up in the root of your project then change your build line in package.json to:

"build": "next build && cp _redirects .next/",

That puts the file in the right place at the end of the build process.

via: https://docs.netlify.com/routing/redirects/

which says: "Save a plain text file called _redirects without a file extension to the publish directory of your site." but doesn't tell you how to actually do it.

TODO: put in syntax

Note: saw this in the build page of netlify:

A _redirects file is present in the repository but is missing in the publish directory ".next".

That was before I pushed it in with that package.json update.

-- end of line --