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

214
Vistas
Is possible to get the last string of an url as a param?

I cant get it with javascript URLSearchParams function because it needs the "?" before.

Its possible to get the last string after last slash of an URL?

For ex: 
mydomain.com/hello
mydomain.com/otherExample

I need that "hello" be the param and stay in the index of my domain with the "param" value assigned to a var? Note that the "hello" page or directory doesn't exists.

Maybe is possible to manage it with the 404 error redirection?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You should be able to retrieve it with the following Javascript:

let parts = window.location.pathname.split('/');
let path = parts[parts.length - 1];
about 4 years ago · Juan Pablo Isaza Denunciar

0

The Location object has a property that does exactly what you want:

window.location.pathname

If you don't want the initial slash, you can remove it like so:

window.location.pathname.substring(1)

Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Location

about 4 years ago · Juan Pablo Isaza Denunciar

0

In .htaccess file you can redirect to your index without change the URL.

After, you must handle the window.location.pathname as they have told in other messages.

.htaccess file

RewriteEngine On
RewriteRule ^(.*)$ index.html
about 4 years ago · Juan Pablo Isaza Denunciar
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