DEV Community

sundaycrunk
sundaycrunk

Posted on

Answer: On page refresh getting "404 not found" error in react js

This is really simple.

Create a .htaccess file on /public_html folder and copy that code:

RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

If you want to know about the process, read this article: https://ui.dev/react-router-cannot-get-url-refresh/

Oldest comments (0)