Forum Moderators: coopster
$ft = @fopen("http://www.example.com", "r") or die( "Didn't get it!");
It works, but what I want to know is sometimes "http://www.example.com" may actually be redirected to some other site. The FOPEN function sucessfully reads the site content when it is redirected and I would like to obtain the url it is redirected to and put it into a variable.
For example, if [example.com...] redirects to [xyz.com...] is there a way to find out and store it like $redirected_url = 'http://www.example2.com'?
Any ideas appreciated.
[edited by: jatar_k at 8:00 pm (utc) on Feb. 1, 2005]
is there a way to find out and store it like $redirected_url = 'http://www.xyz.com'?
Redirection is typically done using "Location" header, you will need to analyse headers for that, typically response code will be 301 (Moved permanently). Note that this is not an unusual scenario when you request directory but you did not have '/' at the end: www.example.com/somedir would cause redirect to www.example.com/somedir/