Jump to content

cURL help needed - redirect


generaltso

Recommended Posts

I have a script set up that I need to log in to a site. All is well and good, and the site goes to redirect. Lets say that the final result I want to see is this:

 

www.remotesite.com/anydir

 

However, the final result of the cURL is:

 

www.mysite.com/anydir

 

resulting in a 404 error code since I don't have /anydir on my server (it is on the remote server). I have battled with the cURL settings for the past couple days and nothing seems to work. Here is what I have right now:

 

curl_setopt($ch,CURLOPT_URL,$url);

curl_setopt($ch,CURLOPT_MAXREDIRS, 0);

curl_setopt($ch,CURLOPT_FOLLOWLOCATION, 0);

curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch,CURLOPT_POST,count($fields));

curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

 

curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiejar');

curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiejar');

curl_setopt($ch, CURLOPT_COOKIE, "cookiejar");

 

This is frustrating! any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/137447-curl-help-needed-redirect/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.