PHP cURL redirect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tangoking
Forum Newbie
Posts: 9
Joined: Tue Sep 22, 2009 4:31 pm

PHP cURL redirect

Post by tangoking »

I'm trying to use cURL to redirect the user from my page to another site, but the new URL does not display in the address bar.

For example, http://www.foo.com/transfer.php should redirect the user to http://www.bar.com/index.php. The following code fetches bar.com/index.php, but still displays foo.com/transfer.php in the address bar.

I want to completely transfer control to the new site. Any suggestions? Here's the code that I'm using.

Code: Select all

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.google.com");
curl_exec ($ch);
curl_close ($ch); 
 
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP cURL redirect

Post by jackpf »

Just send a location header with header().
tangoking
Forum Newbie
Posts: 9
Joined: Tue Sep 22, 2009 4:31 pm

Re: PHP cURL redirect

Post by tangoking »

tyvm!
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP cURL redirect

Post by jackpf »

:)
Post Reply