What are common mistakes that can prevent PHP header('Location:..) redirection from working properly?

Common mistakes that can prevent PHP header('Location:..) redirection from working properly include outputting content before the header function, using relative URLs instead of absolute URLs, and not using exit() or die() after the header function. To solve this issue, make sure to call the header function before any output is sent to the browser, use absolute URLs for the location parameter, and terminate the script immediately after the header function is called.

<?php
// Correct way to redirect using header function
header('Location: http://www.example.com');
exit(); // or die();
?>