How to redirect a page with header?

by elise_daugherty , in category: Third Party Scripts , 7 months ago

How to redirect a page with header?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by tressie.damore , 7 months ago

@elise_daugherty 

To redirect a page using PHP with the header function, you can use the following code:

1
2
3
4
<?php
header("Location: http://example.com/newpage.php");
exit();
?>


Make sure to replace "http://example.com/newpage.php" with the URL of the page you want to redirect to. The exit() function is important to stop the execution of any further code after the header redirect.


Keep in mind that header redirection must be done before any content is outputted to the browser. Otherwise, you may encounter errors or warnings.

Related Threads:

How to redirect page in codeigniter?
How to redirect a page in node.js?
How to redirect to a php page?
How to redirect page after login in PHP?
How to redirect based on page in woocommerce?
How to redirect page to https in php?