Page 1 of 1
url after redirected
Posted: Tue Jun 19, 2007 9:11 pm
by diamondnular
Hi all,
Is there any way to grab the final url after you go to an url and are redirected? For example, you have the source url
http://www.source and if you go to that url, you will be redirected to
http://www.destination. I want to grab that destination url but do not know how. Please help.
Thanks,
KC.
Posted: Tue Jun 19, 2007 9:14 pm
by feyd
Grab it in.. PHP? Well, that all depends on how the redirection is done. If it's done with headers,
cURL,
fsockopen(), even
get_headers() among others can give you the headers. If it's done via <meta> or Javascript, you'll have to parse the response yourself.
Posted: Tue Jun 19, 2007 9:14 pm
by superdezign
Which are you trying to get the destination from? The destination or the source?
Posted: Tue Jun 19, 2007 9:22 pm
by diamondnular
feyd wrote:Grab it in.. PHP? Well, that all depends on how the redirection is done. If it's done with headers,
cURL,
fsockopen(), even
get_headers() among others can give you the headers. If it's done via <meta> or Javascript, you'll have to parse the response yourself.
Hi feyd, is there a way to know that the redirection is done by something? I even do not know how it is redirected
superdezign wrote:Which are you trying to get the destination from? The destination or the source?
Hi superdezign, I want to create a php script, in that I can paste the source url, and after running it, it will give out the destination url.
Thanks,
KC.
Posted: Tue Jun 19, 2007 9:32 pm
by feyd
If you don't know where the redirection may be, you will have to parse the data yourself. I've already linked to the functions needed.
Posted: Thu Jun 21, 2007 11:52 am
by diamondnular
Hi feyd,
If the url keeps unchanged after redirected, does that mean redirect is done by server or htaccess? If that is the case, can we make a php script to catch the final url? I try to use curl, but the final url is... still the source one
Thanks,
KC.