Hey,
How can I do this in PHP? e.g.
bit.ly/f00b4r ==> http://www.google.com/search?q=cute+kittens
In Java, the solution is this:
You should issue a HEAD request to the url using a HttpWebRequest instance. In the returned HttpWebResponse, check the ResponseUri.
Just make sure the AllowAutoRedirect is set to true on the HttpWebRequest instance (it is true by default). (Thx, casperOne)
And the code is
private static string GetRealUrl(string url)
{
WebRequest request = WebRequest.Create(url);
request.Method = WebRequestMethods.Http.Head;
WebResponse response = request.GetResponse();
return response.ResponseUri.ToString();
}
(Thx, Fredrik Mork)
But I want to do it in PHP. HOWTO? :)