Hi,
Is there a way to use cURL to redirect, but have the URL change to the new page?
I have the following, but the URL remains as that of the original page after the redirect:
Thanks.
Is there a way to use cURL to redirect, but have the URL change to the new page?
I have the following, but the URL remains as that of the original page after the redirect:
Code:
<?php $url = "http://www.mydomain.com/test3.php"; $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s curl_setopt($ch, CURLOPT_POST, 1); // set POST method curl_setopt($ch, CURLOPT_POSTFIELDS, "test=hello&test2=there"); // add POST fields $result = curl_exec($ch); // run the whole process curl_close($ch); echo $result; ?>