Redirect php to another page

  • 27
  • Tired of reading? Press play to listen instead. N/B. Might not work on some articles

    Ready


You can simply use the PHP header() function to redirect a user to a different page.

The PHP code in the following example will redirect the user from the page in which it is placed to the URL http://www.example.com/another-page.php. You can also specify relative URLs.


<?php
header("Location: http://www.example.com/another-page.php");
exit();
?>

If you want to redirect the users from old page to a new page on a permanent basis then also mention HTTP response code in the header() function as shown in the following example, so that search engines transfer "page rank" from the old page to the new page.

<?php
// 301 Moved Permanently
header("Location: http://www.example.com/another-page.php", true, 301);
exit();
?>

Read: How to Set Up an HTML Redirect on Your Website

Credits: Tutorial Republic

If you need specific help, contact our Support Team.

Feel free to click the thumbs up below to help many others in need of similar solutions, thank you and God bless!

 

 


Was this answer helpful?

« Back

Say Hello

Let's get you started