Forum Moderators: coopster

Message Too Old, No Replies

Is there a way to find out what a url redirects to in PHP?

         

JMusic

1:54 am on Aug 18, 2007 (gmt 0)

10+ Year Member



Every day on my blog, I have a list of about 30 other blogs that I link to. Lately, more and more of then have been using feedburner, which means that the links to their posts show up like this:

http://example.com/~r/Jordanisyourhomeboy/~3/144521539/

Is there a function in php (I'm using PHP 4) that will find out what that URL redirects to, and return the actual URL of the post instead of the feedburner URL?

[edited by: JMusic at 1:54 am (utc) on Aug. 18, 2007]

[edited by: dreamcatcher at 5:54 am (utc) on Aug. 18, 2007]
[edit reason] no urls as per T.O.S [webmasterworld.com].Thanks [/edit]

Habtom

5:20 am on Aug 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



and return the actual URL of the post instead of the feedburner URL?

It actually seems beyond the reach of PHP. Ideas?

SteveLetwin

6:14 am on Aug 19, 2007 (gmt 0)

10+ Year Member



I thought there would be a high-level-ish function to send a request to a web server and then have the headers passed back in an array or hash or something, but I couldn't find it.

However you can write your own using the low-level fsockopen function. [us3.php.net...]

The first example on that page shows the basic use. If you use HEAD instead of GET, then the response will just be the HTTP headers rather than the headers plus the page (saving bandwidth, and possibly (probably?) cpu usage on the remote server). Once you have the headers you can make sure it's a 30x response and then look at the Location header.