How to redirect a page in PHP?

Use the header() function with the Location header to redirect to another page. Always call exit after it, so the rest of the script does not run.

<?php
header("Location: https://tutorialsclass.com/");
exit;
?>

For a permanent redirect, pass the status code as the third parameter.

<?php
header("Location: https://tutorialsclass.com/new-page/", true, 301);
exit;
?>
Note: The header() function must be called before any output (even a space or blank line). Otherwise PHP shows a “headers already sent” warning. See PHP header() function.

Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.