views:

63

answers:

1

What I'd like to do is find out what is the last/final URL after following the redirections.

I would prefer not to use cURL. I would like to stick with pure PHP (stream wrappers).

Right now I have a URL (let's say http://domain.test), and I use get_headers() to get specific headers from that page. get_headers will also return multiple Location: headers (see Edit below). Is there a way to use those headers to build the final URL? or is there a PHP function that would automatically do this?

Edit: get_headers() follows redirections and returns all the headers for each response/redirections, so I have all the Location: headers.