Getting all redirect URLs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Getting all redirect URLs

Post by GeXus »

Does anyone know how you would capture all the URL's that a url redirects to?

For example, let's say the url http://www.example.com/test

Redirects to:

http://www.example.com/test/1
http://www.example.com/test/1/?something=1
http://www.example.com/test/1/?another=1

I would want to print out all of the URL's above that were redirected to. I know in Curl you can follow redirects, but not sure you capture each one.

I
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Getting all redirect URLs

Post by requinix »

You can, with curl_getinfo and CURLINFO_REDIRECT_URL. Stick some code into a loop and you're set.
jh_1981
Forum Newbie
Posts: 22
Joined: Fri Jan 30, 2009 6:21 pm

Re: Getting all redirect URLs

Post by jh_1981 »

Post Reply