title: Trouble reading a query string in a Query String?
body: <p>I have a URL in a query string value that is similar to this one:</p>
  
  <pre><code>example.com/?p1=a1&amp;p2=a2
  </code></pre>
  
  <p>And I have a query sting on my website that takes the URL and redirects to a certain page. Like this:</p>
  
  <pre><code>mysite.com/?url=example.com/?p1=a1&amp;p2=a2
  </code></pre>
  
  <p>But the query string is misinterpreted. How can I separate the query string in the value URL from the actual URL? I have tried encoding the question marks and ampersands, but the page is missing the content from the value URL.</p>
  
  <p><strong>EDIT:</strong>
  This is how I get the URL, through a javascript:</p>
  
  <pre><code> function nameps(url) {
                              url = url.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                              var regexS = "[\\?&amp;]" + url + "=([^&amp;#]*)";
                              var regex = new RegExp(regexS);
                              var results = regex.exec(window.location.href);
                              if (results == null) return "";
                              else {
                                  return results[1];
                              }
                          }
  </code></pre>