Woadud Akand
Woadud Akand

Reputation: 748

My React site only show home page, all other pages not found after upload on live server

My React site working fine on local server but when upload on live server it not work properly without homepage. I use homepage link, use .htaccess file on public folder.

import React from 'react';
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
<Router basename={process.env.PUBLIC_URL} >        
     <Switch>
          <Route exact path = '/' component = { Index } />
          <Route path = '/index2' component = { Index2 } />
          <Route path = '/index3' component = { Index3 } />
     </Switch>
</Router>```

Upvotes: 3

Views: 738

Answers (1)

Shamim
Shamim

Reputation: 236

To solve this problem, add the below code in your .htaccess file and place it on your build folder. Hope this will solve your problem :)

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

Upvotes: 2

Related Questions