获取 URL 位置路径名



假设我有一个虚拟的网站网址:http://company.com/something。

我需要抓取路径:/something 并使用开关大小写使用 javascript 重定向到新的 URL。

有人可以指导我吗?

var URL;
var url_param = location.pathname;
switch(url_param) {
     case "/how-to-do-this":
          URL = '/your-new-destination/';
     default:
          URL: '/thankyou/';
console.log("your new URL is: " + URL);

谢谢。

我假设你正在使用Javascript

var URL;
switch(window.location.pathname) {
     case "/how-to-do-this":
          URL = '/your-new-destination/';
     default:
          URL= '/thankyou/';
}
console.log("your new URL is: " + URL);

最新更新