title: How to Url encode nested query strings
body: <p>I have a the following url:</p>
  
  <blockquote>
    <p><a href="http://www.test.com/?client=xyz&amp;redirect_uri=http://www.xyz.com/x?p1=one&amp;p2=two" rel="noreferrer">http://www.test.com/?client=xyz&amp;redirect_uri=http://www.xyz.com/x?p1=one&amp;p2=two</a></p>
  </blockquote>
  
  <p>How should I url encode these so that the browser does not interpret p1 and p2 as query strings of the <code>test.com</code> when they are actually part of the <code>redirect_uri</code> parameter.</p>