2

I need to do 2 things:

  • Pass couple of parameters to querystring
  • Redirect to URL given in one of parameters

One of the parameters is redirect=URL_here. The problem is, that i must redirect to that page: /about/me?look=1&sort=asc Then, my URL looks like:

/mypage/?letter=S&redirect=/about/me?look=1&sort=asc

I know that this is wrong (contains two "?"). The question is, how to make that query string correctly?

3 Answers 3

2

URL encode the query string values.

Sign up to request clarification or add additional context in comments.

Comments

0

change = sign with your own like || on your link. In your case change link like this
/about/me?look||1&sort||asc

Then later you will change || with =

Comments

0

Use Url encode

Like this

<script>
var c= 'd e'
var query= '?a=b&c='+encodeURIComponent(c);
var uri= 'http://www.example.com/script?query='+encodeURIComponent(query);
window.location= uri;
</script>

and use

 decodeURIComponent()

to decode

3 Comments

There is no way to put JS anywhere. The only way I can do it is to prepare proper query-string - it's used in closed system, and code can't be changed.
then replace your ? and & with other special char like mypage/?letter=S&redirect=/about/me*look=1^sort=asc
What is the benefit of that? If I'll change look=1& to look=1^ How will it work then?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.