title: How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header
body: <p>My code was working fine:</p>
  
  <pre><code>$registrado = "no";
  
  $redirect_url = site_url( "/pedido-nao-recebido/?mpms2pagarme=retorno&amp;codigo=nao200&amp;mensagem=oui&amp;registrado=$registrado");      
  
  wp_redirect($redirect_url);
  
  exit;
  </code></pre>
  
  <p>With this, I was being redirected to</p>
  
  <pre><code>http://s16138.p360.sites.pressdns.com/pedido-nao-recebido/?mpms2pagarme=retorno&amp;codigo=nao200&amp;mensagem=oui&amp;registrado=no.
  </code></pre>
  
  <p>Exactly what I need.</p>
  
  <p>Then I decided to take a security measure, with <code>wp_nonce_url</code>.</p>
  
  <pre><code>$registrado = "no";
  
  $redirect_url = site_url( "/pedido-nao-recebido/?mpms2pagarme=retorno&amp;codigo=nao200&amp;mensagem=oui&amp;registrado=$registrado");      
  
  //WP Nonce (security measure)
  $nonce_redirect_url = wp_nonce_url( $redirect_url, 'pedido-nao-recebido', 'mpms2nonce' );
  
  wp_redirect($nonce_redirect_url);
  
  exit;
  </code></pre>
  
  <p>Now I get this URL:</p>
  
  <pre><code>http://s16138.p360.sites.pressdns.com/pedido-nao-recebido/?mpms2pagarme=retorno&amp;amp;codigo=nao200&amp;amp;mensagem=oui&amp;amp;registrado=no&amp;amp;mpms2nonce=aeb5ba40d2.
  </code></pre>
  
  <p>Because of these <code>amp;</code>, my code is broke and browser gives me a <code>The s16138.p360.sites.pressdns.com page isn’t working</code>. There is a script on the redirected page that is not running. It goes like this:</p>
  
  <pre><code>//If it is not a subscription request, abort...  
  if ( !isset( $_GET['mpms2pagarme'] ) || 'retorno' != $_GET['mpms2pagarme'] || !isset( $_GET['codigo'] ) || !isset( $_GET['mensagem'] )  ) {  
      return;  
  }
  
  //Checking WP Nonce
  check_admin_referer( 'pedido-nao-recebido', 'mpms2nonce' );
  
  (...)
  </code></pre>
  
  <p>I tried using php <code>header</code> function instead of <code>wp_redirect</code>, but the same happened (ampersand). I tried also <code>esc_url</code>, <code>esc_url_raw</code>, <code>urlencode</code>...with no success.</p>
  
  <p>Strange thing...<code>wp_redirect</code> (or <code>header</code>) only works for me without <code>wp_nonce_url</code>. Should I get rid of the latter? Any other solution?</p>
  
  <p>Thanks in advance.</p>