What are the best practices for setting up redirects in PHP to avoid issues with file directories?

When setting up redirects in PHP, it's important to use absolute paths rather than relative paths to avoid issues with file directories. This ensures that the redirect works correctly regardless of the current directory or file structure. By using absolute paths, you can avoid potential errors and ensure that your redirects function as intended.

// Example of setting up a redirect with an absolute path
header("Location: http://www.example.com/newpage.php");
exit();