Page Not Found Error - Redirects File

Netlify Site name: elegant-duckanoo-727972

Hi Support! I’m trying to deploy a react multi-page site with react-router-dom for the first time. The deployment is successful/published, however when I go to the site I am getting the Page Not Found error.

I have added the _redirects file to my site with the below contents.
/* /index.html 200

I’ve attached a screenshot of my site structure in VS Code which you might find helpful.

Any ideas why I am still getting the Page Not Found error?

Hello @melzopla , thanks for posting.

  1. I want to find out if the site works when you remove the _redirects?
  2. Which method did you use to deploy the application (Netlify Dashboard UI or Netlify CLI)?
  3. What settings did you specify for the base, build command, and publish directory during deployment?

Thanks

Hi @clarnx ,

Thank you for your message! Please see my replies below.

  1. The site does not work if I remove the redirects file.
  2. I used the Netlify Dashboard UI for deploy.
  3. Base, build command and publish directory are all “not set” at the moment.

Thanks

Hi @melzopla , thanks for the extra feedback.
Kindly set the following below since your framework is React.js

  • Build command: npm run build
  • Publish directory: build/

You can learn how to set the settings above from the Netlify Dashboard UI by visiting the link below.

Let me know if the above works.
Hope this helps.

Hi @clarnx ,

Thanks for the advice - I tried this but when I try to redeploy the build now fails. I have attached a screenshot from netlify deploy log.

Thanks

Hello @melzopla , if possible can you share a link to the repository where you are trying to deploy from. That’s if it’s public and does not contain private information?
It seems your base directory is the problem.

Hi @clarnx,

Sure, no problem. I’ve copied the site to a public repository which you can find here: https://github.com/ozlemalp/tester-react-multi

I had to change the Netlify site, it’s now “delightful-sorbet-b7eb47”

Also code/settings/errors etc. remain the same.

Thanks

Hi @melzopla , thanks for sharing.

  • Base directory: optional field for linking monorepos or sites built from a subdirectory of a repository. It specifies the directory that our buildbot changes to before starting a build. It’s where our build system checks for dependency management files such as package.json or .nvmrc. If not set, the base directory defaults to the root of the repository.

Kindly set the following below when deploying.

  • Base directory: my-app/
  • Build command: npm run build
  • Publish directory: build/

Let me know the outcome. Thanks.

@clarnx, you legend - it worked :smiley:

Although it overwrote the publish directory to “my-app/build/” rather than “build/”

Thanks so much!!

1 Like

Hi @melzopla , Glad I was able to help.

The above is correct since your base folder is my-app

If you are satisfied with the suggested solution, kindly mark it as solved.

1 Like