curl を使用してリモート URL に値を送信しようとしています。しかし、リモート サイトが別のページにリダイレクトされ、問題が発生しています。
たとえば、www.mywebsite.com から URL www.domain.com/index.php に値を送信すると、index.php は fetch.php ファイルにリダイレクトされますが、実際には www.mywebsite.com/fetch のように開きます。このファイルは私のものではなくリモートサイトにあるため、404 not foundエラーが発生します。どうすればこれを修正できますか
これは私が使用しているコードです
$postfields = "link=xxxxxx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'domain.com/index.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'rap.txt');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
$content = curl_exec($ch);
curl_close($ch);