Usually little setup of Apache and Nginx is needed so they can handle React routes properly without trying to treat them as real files or directories resulting in 404 Not Found in React.
Here are the snippets of the React routes related settings for Apache and Nginx.
Within Apache Directory
directive of add:
1 2 3 4 5 6 7 |
<Directory /var/www/html/reactapp/> RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) RewriteRule ^([^?]*) index.html?_route_=$1 [L,QSA] </Directory> |
Within Nginx location
directive of add:
1 2 3 4 |
location / { root /var/www/html/reactapp; try_files $uri /index.html; } |
Good luck!