0

I am getting Not Found error when i am hard reloading the page but it works fine i do normal reload with build .Here is my Router tag. I did not use createBrowserHistory. Is it the issue?

<Router basename={process.env.PUBLIC_URL}>
           <Switch >
          <div >
            <Navbar />
            <Route exact path="/" component={HomeComponent} />
            <Route exact path="/score/:id" component={ScoreComponent} />
            <Route exact path="/login" component={LoginComponent} />
            <Route exact path="/forgotPassword" component={ForgotPasswordComponent} />
          </div> 
          </Switch >
      </Router>

2 Answers 2

10

I resolve this issue by below .htaccess code

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.html [L]
</IfModule>
Sign up to request clarification or add additional context in comments.

1 Comment

such a helpful answer, I was looking for this solution since so long. Thank you so much
0

You get the 404 because the router doesn't figure out which path to choose. What if you use the Redirect tag as a catch all other cases kind of thing?

1 Comment

i think this is not issue. the error is given by Apache is here . Not Found The requested URL /index.html was not found on this server. Apache/2.4.7 (Ubuntu) Server at localhost Port 80

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.