Page refresh error on static website in react

Viewed 65

I made a static website application in React. localhost is working. but when I upload it to the server, I get a page not found error when I refresh the page on pages other than the home page. What is the solution?

1 Answers

Create .htaccess file on the Server and past below code in the file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /subdirectory
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule . /index.html [L]
</IfModule>
Related