Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!