How can PHP be used to handle redirection for users with JavaScript disabled?

When users have JavaScript disabled, they may not be able to be redirected using client-side JavaScript. In this case, PHP can be used to handle redirection by checking if JavaScript is disabled and then redirecting the user using server-side code.

<?php
if(isset($_GET['redirect'])) {
    $redirect_url = $_GET['redirect'];
    header("Location: $redirect_url");
    exit();
}
?>