Date: Fri, 23 Dec 2005 10:04:16 +0000
From: Yemi Obembe <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: using fsockopen to handle redirections

Any way i can use fsockopen to detect url redirections? for example if ds:
www.ex1.com redirects to www.ex2.com and i'm using:

$fp = fsockopen(www.ex1.com, 80)

to connect to the site, anyway i can know if there is a redirection to
another url?


Probably rather than fsockopen it would be helpful to use the CURL library to make the connection(s). You should install the CURL extension to PHP, more information at http://uk2.php.net/curl and http://www.zend.com/manual/function.curl-setopt.php (^Find : CURLOPT_FOLLOWLOCATION)

This page http://curl.haxx.se/mail/curlphp-2002-02/0005.html contains useful discussion about that. Basically you'll want to set CURLOPT_FOLLOWLOCATION which will allow CURL to respond to the redirect header as if it was a browser.

If you're not using CURL then you've got significant extra work to look at each individual header sent by the redirecting web server to determine which header is the redirect and which location it's sending you to (probably using a regex).

Cheers - Neil

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to