I am building movie app, initialize with create-react-app. I am using react-router@5
. I get 404 Error when route url on production (on Litespeed webserver) but it's work on local machine.
Example Url :
www.example.com/tv/detail/131959
I am research on issue and found .htaccess
file configuration, but configuration for apache or tomcat and I use litespeed web server.
AppRouter.js
const AppRouter = () => {
return (
<BrowserRouter >
<Navbar />
<ScrollToTop />
<Switch>
<Route exact path="/" component={App} />
<Route exact path="/:type/detail/:id" component={DetailPage} />
</Switch>
</BrowserRouter>
)
};
For inspect visit github repo: https://github.com/egecanyldrm/movie_app
.htaccess config
<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>