# Problem when navigating routing

**URL:** <https://answers.netlify.com/t/problem-when-navigating-routing/98037>\
**Category:** Support\
**Tags:** redirects\
**Created:** [August 1, 2023, 2:29am UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037 "2023-08-01T02:29:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChikenMcSwag](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/chikenmcswag/32/53225_2.png) [@ChikenMcSwag](https://answers.netlify.com/u/ChikenMcSwag)\
**Post date:** [August 1, 2023, 2:29am UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037/1 "2023-08-01T02:29:52Z")

</div>

I just deployed my react webapp unto netlify, it works great but there is one problem where in my page I got several buttons that navigate to another page. However, when I click that button rather than sending me to that page, it says Page not found even though I can tell that the link I want to go to exists since I use navigate in another place on my webapp as well to the same link and that button works. One reason that I could think of is for that specific button, after I click it, the page reloads which might cause the problem I mentioned before, so is there anyway of allowing me to access links even after reloading.

Ps. Lets say the website’s domain is [www.example.com](http://www.example.com), I want to go to [www.example.com/test](http://www.example.com/test)

 ![image](https://global.discourse-cdn.com/netlify/original/3X/8/c/8ce79b4ba45adea4fdc3b3db1840318cb5d7e33f.png)

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [August 1, 2023, 7:00pm UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037/2 "2023-08-01T19:00:08Z")

</div>

This issue is commonly encountered when deploying single-page applications (SPAs) like React on Netlify. The problem arises because when you navigate to a different route in your application, Netlify tries to serve a file that matches that route. However, in SPAs, all routes are handled by a single `index.html` file.

To fix this, you need to add a `_redirects` file to your project with the following content:

```auto
/* /index.html 200

```

This rule tells Netlify to redirect all routes to the `index.html` file, which then allows your React router to handle the route correctly.

You should place the `_redirects` file in the `public` folder of your React application. After adding the file, you need to redeploy your application on Netlify.

Please take a look at the support guide below as it details this error in greater detail.

> [@\[Support Guide\] I’ve deployed my site but I still see "Page not found”](https://answers.netlify.com/t/support-guide-i-ve-deployed-my-site-but-i-still-see-page-not-found/125):
>
> Last reviewed by Netlify Support - August, 2023 Netlify attempts to lookup a file based on several xor filters, and when all of these fail, we end up serving a 404 page. For example, a request made to /example/ would check /example/index.html, /example.html, /example/home.html and several other combinations (not necessarily in the same order) before hitting the 404. However, in case you were not expecting a 404 at a particular URL, you might be interested in finding out the reason and potentia…

You can find more information about redirects in the [Netlify documentation](https://docs.netlify.com/routing/redirects/).

If you’re using `react-router-dom`, you might also need to switch from `BrowserRouter` to `HashRouter`, as few folks found this solved their routing issues.

---

<div class="post-metadata">

**Author:** ![timone019](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/timone019/32/58779_2.png) [@timone019](https://answers.netlify.com/u/timone019)\
**Post date:** [February 16, 2024, 2:52am UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037/3 "2024-02-16T02:52:41Z")

</div>

Ran into a similar issue where everything works in local host but on the live netlify hosted site, certain endpoints when page is refreshed, we get that 404 error. The netly.toml file looked correct but after a whole day of trying different things it turns out that the netlify file wasn’t in the root folder as it was accidentally created i. the src folder and when everything is expanded in vs code, our human eyes really couldn’t tell. After moving the netlify.toml file to the root folder, that fixed the issue so for anyone else encountering this issue, do check if it really is in the root folder.

---

<div class="post-metadata">

**Author:** ![SamO](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/samo/32/41847_2.png) [@SamO](https://answers.netlify.com/u/SamO)\
**Post date:** [February 16, 2024, 4:10pm UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037/4 "2024-02-16T16:10:33Z")

</div>

hey! 👋🏿 thanks for sharing this insight with the community @timone019 this is super helpful for folks chiming into the forums in the future.

---

<div class="post-metadata">

**Author:** ![yeniv](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/yeniv/32/68277_2.png) [@yeniv](https://answers.netlify.com/u/yeniv)\
**Post date:** [March 19, 2025, 12:31am UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037/5 "2025-03-19T00:31:23Z")

</div>

Thank you, @SamO! Adding the `_redirects` file solved my issue.

---

<div class="post-metadata">

**Author:** ![arthurwg](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/arthurwg/32/69176_2.png) [@arthurwg](https://answers.netlify.com/u/arthurwg)\
**Post date:** [April 28, 2025, 10:41pm UTC](https://answers.netlify.com/t/problem-when-navigating-routing/98037/6 "2025-04-28T22:41:39Z")

</div>

Thanks for the answer,

> If you’re using `react-router-dom` , you might also need to switch from `BrowserRouter` to `HashRouter` , as few folks found this solved their routing issues

After trying many different solutions this simple change worked for me , changed from BrowserRouter to HashRouter and it works now.
