Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
How to make ReactRouter ignore an URL?

I am hosting my React project on Apache and had to redirect requests using the .htaccess file. It's in React, but also uses vanilla javascript and HTML sites.

In production (npm start), here is how it worked:

If the site got certain tokens from Firebase, the page would get redirected to the site like this:

{HaveToken ? (
      
     <BrowserRouter>
       <Route exact path="/" render={() => {window.location.href="tv/indextv.html?m="+auth.currentUser.email+"&p="+othermail+"&t="+othertoken}} />
       
      </BrowserRouter>
    ):null}

If it did not, the return statement of the function would just go on, rendering other things. On the html/javascript site, with on click of a button, It would then get redirected to this same App.js project, with this line:

window.location.href = 'http://localhost/messages';

It would just run the App.js, and it worked perfectly, it wouldn't get rerouted again because it's no longer just "/".

Now that I built it, and added it to an Apache server, it works differently. For /messages, I get a 404 error, for... well, obvious reasons.

My question is, how can I fix this problem? I tried to do it by adding something like localhost?m=m so the location would be the same, but the URL is slightly different. Sadly, Route still thinks it's the same path. Is there any way I can make Route only render the other site if they did not get here by clicking a button on the other site? Or can I pass something from the other site that could make Route ignore that it's the same path?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda