Wednesday, 24 May 2017

How to redirect to the base URL if the given URL ends with a slash?

I have this link http://localhost:3007/sellers-toolkit/, but the right page is only the one without a trailing slash. So I would like a redirection to http://localhost:3007/sellers-toolkit.

I tried to write this part in JavaScript, but it just makes the page reload and nothing happens. What is the right way to achieve this behavior?

var url = "http://localhost:3007/sellers-toolkit/";
if (url) {
  url = "http://localhost:3007/sellers-toolkit";
  window.location.href = url;
}



via Hesham El Masry

No comments:

Post a Comment