I host mine react project to Namecheap server. It's working fine, but when I go to about or other pages and reload this page the page is gone and it shows me a 404 error. why did I get a 404 error and how to fix it?
Asked
Active
Viewed 169 times
0
-
You need to configure your server to redirect your request to index.html instead of 404 page. nginx example: ` try_files $uri /index.html;` – Wraithy Jan 25 '22 at 12:28
-
I'm sorry, I don't understand. Do you have any usefull resources for this issue? – Sumon Chandra Jan 25 '22 at 12:32
-
try this question: https://stackoverflow.com/a/47505427/16116506 – Wraithy Jan 25 '22 at 12:35
1 Answers
0
Create a .htaccess file on your root folder and paste the following code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>

Chandan Bisht
- 55
- 3