saftutorials.com
PHP Redirects Tutorial

You can make a redirecting page to another page by using PHP. There are many types redirect system in PHP. Below example:


1. Regular redirect

<?php 
     header('Location: redirectpage.php');
?>



2.using header function with exit()

<?php 
     header('Location: redirectpage.php');exit();
?>



3.without header

<?php 
    echo "<script>location.href='redirectpage.php';</script>";
?>



4.using header function with ob_start() and ob_end_flush()

<?php
ob_start(); // this should be first line of your page
header('Location: redirectpage.php');
ob_end_flush(); // this should be last line of your page
?>



5. Header location change after sometime

<?php
header('refresh:5;url=redirectpage.php '); // Note: here 5 means 5 seconds wait for redirecting.
?>



6. Redirect with a Variable data

<?php
$redirectURL = "http://www.saftutorials.com";
header('Location: '.$redirectURL ;

?>


Find us on

Facebook Google Plus Twitter Pinterest YouTube

web statistic