@Kenny E if you're trying to keep the QS and pass it verbatim to another page, your approach isn't correct:
- String::split() returns an array and by defintion does not include the "?" character.
- It's not necessary to parse location.href at all: location.search already contains the query string.
- Using scheme-relative URL "//..." means you will never redirect from http:// to https:// or https:// to http://, which is a big assumption.
The correct way is:
window.location.href = "http://redirect.example.com" + window.location.search;
However from the OP's example he isn't using the original QS but rather massaging it into a different hostname and path. There isn't any magical way to do this except a series of case statements or regexes.