What are the indicators of an HTTP redirection and how can it be detected in PHP?
When a website performs an HTTP redirection, it typically sends a status code of 301 or 302 along with a Location header that specifies the new URL. To detect an HTTP redirection in PHP, you can check the status code using the get_headers() function or by inspecting the response headers using cURL.
$url = 'http://www.example.com';
$headers = get_headers($url, 1);
if (strpos($headers[0], '301') !== false || strpos($headers[0], '302') !== false) {
$newUrl = $headers['Location'];
echo 'Redirected to: ' . $newUrl;
}