_redirects set up and working in Netlify Dev locally, but doesn't work after published

My website’s (https://warm-elf-8a7243.netlify.app) redirects aren’t working, despite being set up as perfect as I can tell from the documentation, and being put into the right location when deploying.

My site is built using Vite into a dist folder, so I have a postbuild script that runs in order to copy the _redirects file from the root of my repo, into the dist folder.

Upon deploying, I can see in the build output, the message: “A “_redirects” file is present in the repository but is missing in the publish directory “dist”.”

The contents of my _redirects file is simply:

/*           /dist/index.html           200

I have tried with /index.html instead of /dist/index.html, however that also didn’t work, and also doesn’t match the format that I’m using in another Netlify project where the redirects are working perfectly fine…

When running netlify dev locally, the _redirects appear to work perfectly fine, as I’m able to refresh the page and get pushed to index.html appropriately…

What am I missing?

@denno020 It sounds like a couple of things might be wrong/odd here.

You can certainly manually copy the file from the root into your dist folder using your own script, but you could achieve the same with Vite’s Static Asset Handling, specifically the Public Directory.

If you had the file as /public/_redirects it would get copied to /dist/_redirects for you during build.

Secondarily, the redirect that you have specified includes /dist/ as a path to redirect to, however you’ve said that dist is the folder that you’re deploying, thus it doesn’t exist in the paths.

So what you want is likely the standard

/*  /index.html  200

Thank you mate… I know I had tried that already, both the public directory and the _redirects content, but I guess I didn’t try them at the same time…
Anyway, your suggestion worked spot on, thanks

yay! Glad to hear Nathan’s solution got you sorted. thanks for coming back and confirming. happy building. :rocket: :netliconfetti: