title: Stop redirecting when refresh page in react.js
body: <p><strong>I am using react-router-dom</strong></p>
  <p>Below I have attached my code</p>
  <pre><code> let route =
      &lt;Switch&gt;
       &lt;Route path=&quot;/support_login/:token&quot; component={SupportLogin}/&gt;
       &lt;Route path=&quot;/login&quot; component={Login}/&gt;
       &lt;Route path=&quot;/signup&quot; component={Signup}/&gt;
      &lt;LandingPageLayout&gt;
          &lt;Route path=&quot;/&quot; component ={Landingpge}/&gt;
          &lt;Redirect to=&quot;/&quot;/&gt;
      &lt;/LandingPageLayout&gt;
     &lt;/Switch&gt;
   if(props.token){
     route = &lt;Layout&gt;
       &lt;Route path=&quot;/logout&quot; component={Logout}/&gt;
       &lt;Route path=&quot;/dashboard/packages&quot; exact component={Packages}/&gt;
       &lt;Route path=&quot;/dashboard/payments&quot; exact component={Payments}/&gt;
       &lt;Route path=&quot;/dashboard/billings&quot; exact component={Billings}/&gt;
       &lt;Route path=&quot;/dashboard/snapshots&quot; exact component={Snapshots}/&gt;
       &lt;Route path=&quot;/dashboard/vpn_servers&quot; exact component={VpnServers}/&gt;
       &lt;Route path=&quot;/dashboard/cloud_servers&quot; exact component={CloudServer}/&gt;
       &lt;Route path=&quot;/dashboard/profile&quot; exact component={Profile}/&gt;
       &lt;Route path={`/dashboard/server_details/:server_id`} exact component={ServerDetails}/&gt;
       &lt;Route path=&quot;/dashboard/create_vpn_server&quot; exact component={CreateVpnServer}/&gt;
       &lt;Route path=&quot;/dashboard/create_cloud_server&quot; exact component={CreateCloudServer}/&gt;
       &lt;Route path=&quot;/dashboard&quot; exact component={Dashboard}/&gt;
       &lt;Redirect to=&quot;/dashboard&quot;/&gt;
     &lt;/Layout&gt;
    }
  </code></pre>
  <p>Now if refresh any route from the browser, I am redirecting to &quot;dashboard&quot;  or &quot;/&quot; based on the token. But If I remove  it works. But when I have a false URL found, I need to be redirected. Now, How may I achieve this?
  How to stop redirecting to root or &quot;/dashboard&quot;, if I refresh any page?</p>
  <p>What I need is, if I reload or refresh a page from a browser, I want to be redirected to the path I was before refreshing or reloading. Rather than redirecting to &quot;/&quot; or &quot;dashboard&quot;</p>
  <p>I am in</p>
  <pre><code>&lt;Route path=&quot;/dashboard/create_cloud_server&quot; exact component= 
   {CreateCloudServer}/&gt;
  </code></pre>
  <p>and I refresh the URL from the browser or reload it, It redirecting me to</p>
  <pre><code>&lt;Redirect to=&quot;/dashboard&quot;/&gt; 
  //or if not token
   &lt;Redirect to=&quot;/&quot;/&gt;
  </code></pre>
  <p>But I want to get to the original path this one below, as it was the path before reloading url.</p>
  <pre><code>&lt;Route path=&quot;/dashboard/create_cloud_server&quot; exact component= 
   {CreateCloudServer}/&gt;
  </code></pre>