array('method' => 'HEAD')) ); //get_headers follows redirects automatically $headers = get_headers($url, 1); if ($headers !== false && isset($headers['Location'])) { return end($headers['Location']); } return $url; } ?>