|
Posted by Jerry Stuckle on 11/05/97 11:43
Dave wrote:
> Actually, what I ended up doing was to use curl to request a very small
> graphic from the site.
> Used curl timeout to control the redirect time and got just the header.
>
> $timeout = 10;
> $testurl = "www.example.com/small.gif";
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_HEADER, 1);
> curl_setopt($ch, CURLOPT_NOBODY, 1);
> curl_setopt($ch, CURLOPT_URL,$testurl);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
> curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
> $source = curl_exec($ch);
> curl_close($ch);
>
> if ($source!="") // optionally I could have tested for HTTP status, 404,
> 301, etc.
> $url = "http://www.example.com/";
> else
> $url = "http://www.example.net/";
> header("Location: $url");
>
> Thanks to all who responded,
>
> Dave
>
>
> "Karl Groves" <karl@NOSPAMkarlcore.com> wrote in message
> news:Xns9794A94E12584karlkarlcorecom@216.196.97.136...
>
>>Jerry Stuckle <jstucklex@attglobal.net> wrote in
>>news:ZsGdnYorq-4TNrTZ4p2dnA@comcast.com:
>>
>>
>>>Dave wrote:
>>>
>>>>Hi All,
>>>>
>>>>Can anyone suggest a reliable solution to php redirect?:
>>>>
>>>>header("Location: $redir_url");
>>>>if the above times out in $timeout seconds
>>>>header("Location: $alt_redir_url");
>>>>
>>>>Many thanks,
>>>>
>>>>Dave
>>>>
>>>>
>>>
>>>Hi, Dave,
>>>
>>>Sorry, you can't do it.
>>>
>>>When you send the redirect, the request goes to the browser. The
>>>browser is now responsible for fetching the new page. Your script is
>>>no longer "in the loop".
>>>
>>>Maybe you could do it with javascript - I haven't tried. But that
>>>would have its own problems (i.e. user has disabled javascript).
>>>
>>
>>Actually, what could be done is to check for a good response at new URL
>>with fsockopen() and if successful, do the redirect, otherwise go to the
>>alternate.
>>
>>To the OP:
>>peruse the info here: http://us2.php.net/function.fsockopen
>>
>>
>>
>>--
>>Karl Groves
>>http://karlcore.com
>>http://chevelle.karlcore.com
>>
>>Accessibility Discussion List: http://smallerurl.com/?id=6p764du
>
>
>
All this does is mean you can access it from your site at that time.
It doesn't mean, for instance, the user can access it - there may be a
communications problem somewhere between the user and the target site, for instance.
And of course there's the slight chance the site will go down between the time
you request the graphic and the time the redirect takes effect. But the odds of
that happening are pretty remote unless you're doing hundreds of redirects per
minute.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|