What steps can be taken to troubleshoot and resolve PHP redirection issues after a server migration?

Issue: After a server migration, PHP redirection may not work as expected due to changes in server configurations. To troubleshoot and resolve this issue, check the server settings, update the redirection code to ensure compatibility with the new server, and clear any caching that may be affecting the redirection. Code snippet:

// Check if the server supports PHP redirection
if (headers_sent()) {
    // If headers have already been sent, use JavaScript redirection as a fallback
    echo '<script>window.location.replace("new_url.php");</script>';
} else {
    // Use PHP header redirection
    header('Location: new_url.php');
    exit();
}