What common mistake was identified in the PHP script that caused the redirection issue?

The common mistake identified in the PHP script that caused the redirection issue was the presence of output before header functions. To solve this issue, all output must be cleared before using header functions to set redirection headers.

<?php
ob_start(); // Start output buffering

// Your PHP code here

ob_end_clean(); // Clear output buffer
header("Location: https://www.example.com"); // Redirect to the desired URL
exit();
?>