|
|
|
Re: PHP Function to translate a URL into the URL that it is redirected to [message #174672 is a reply to message #174671] |
Mon, 27 June 2011 03:08 |
Michael Vilain
Messages: 88 Registered: September 2010
Karma: 0
|
Member |
|
|
In article <Xns9F107B75698B5arbpenyahoocom(at)88(dot)198(dot)244(dot)100>,
Adrienne Boswell <arbpen(at)yahoo(dot)com> wrote:
> Gazing into my crystal ball I observed Charlie <shymathguy(at)gmail(dot)com>
> writing in news:cd2488ac-2e6b-46e8-bfdc-18349a2db9c0
> @v31g2000vbs.googlegroups.com:
>
>> I need a function FUNCTION(URL1) = URL2 to which URL1 is redirected.
>>
>> And the answer is . . . ?
>>
>> Thanks,
>>
>> Charlie
>>
>
> Is this a quiz? Is this a moved permanently or moved temporarily?
>
> It depends on why you want to do this, .htaccess would probably be the
> preferred method to do this, not PHP.
Actually, the only way I know how to do this is to send a HTTP HEAD
request. It will come back with 301 or 302 and the new location. I
think the OP wants the function to return the redirected URL which would
be useful for updating bookmarks. Or to flag a stale link to be updated
manually.
I didn't think there is such a thing in PHP, but it turns out you can if
you use the curl stuff. Didn't try actually getting anything to work,
but you could futz with
http://us.php.net/manual/en/function.curl-exec.php
and perhaps get the headers of a HEAD request through CURL. That might
get you the info you want.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
|
|
|