What are best practices for handling URL redirections in PHP to avoid design and link issues?

When handling URL redirections in PHP, it is important to use proper HTTP status codes (such as 301 for permanent redirects and 302 for temporary redirects) to ensure search engines and browsers understand the intent of the redirection. Additionally, always include the full URL (including the protocol) in the redirect header to avoid potential design and link issues.

<?php
// Redirect to a new page with a 301 status code
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/new-page");
exit();
?>