title: Redirect after CURL POST doesn't change URL
body: <p>I have a form that sits on my site.  When the form is submitted, it needs to POST that information to an internal (or external) website, and then redirect the browser to that internal (or external) website.</p>
  
  <p>The form is located on <code>https://www.mysite.com/form.php</code></p>
  
  <pre><code>&lt;?php
  $urlToPostTo = 'https://www.mysite.com/postPage.php';
  $urlToRedirectTo = 'https://www.mysite.com/redirectPage.php';
  
  $curlConnection = curl_init($urlToPostTo);
  curl_setopt($curlConnection, CURLOPT_POST, true);
  curl_setopt($curlConnection, CURLOPT_POSTFIELDS, $valuesToPost);
  
  curl_exec($curlConnection);
  curl_close($curlConnection);
  
  header("Location: $urlToRedirectTo");
  exit;
  
  ?&gt;
  </code></pre>
  
  <p>The form posts correctly using CURL, and the final page I see is <code>$urlToRedirectTo</code>, but the URL listed in the browser is still the <code>mysite.com</code> URL.</p>
  
  <p>If the POST and Redirect pages are on an external domain, everything works fine.  The URL in the browser changes and everything.  It is only when it is a same-domain URL that it does this odd behavior.  Generally, it will be posted to an external URL, but I need it to work correctly for when it is an internal URL without having to write separate code.</p>
  
  <p>Note: the URL to be posted to/redirected to comes to me as a variable - I don't know if it will point to an internal or external domain.</p>
  
  <p>Any ideas on how to make it handle the internal redirection correctly (update the browser URL)?</p>