React Router works on local machine, Chrome but not on safari and other browsers,
<Switch>
<Route exact path={"/"} component={Home} />
<Route path="/programs/:slug" component={Programs} />
<Route path="/page/:slug" component={Page} />
<Route component={NotFound} />
</Switch>
thats my code but it works perfectly in development mode no errors but on production, safari gives 404 error when i navigate to programs/:slug or page/:slug
I added this to .htaccess
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(assets/?|$)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
Thanks to Kishan Mundha explanation
You may need to configure single entry point index.html
on server. All url should target to index.html
and entry point will decide how to render and content based on route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With