What are some potential pitfalls of using an automatic redirection to another page in PHP?

One potential pitfall of using automatic redirection in PHP is that it can lead to an infinite loop if not properly handled. To prevent this, you can add a condition to check if the current page is the same as the redirection target before executing the redirection.

if($_SERVER['REQUEST_URI'] != '/target-page.php'){
    header("Location: /target-page.php");
    exit();
}