Redirect page using PHP function header()

Posted by Shek on May 21, 2008 under PHP | Be the First to Comment | Total View: 5,047 views

In some cases, you might like to redirect the user to another page from a certain page, example like when the website is under maintenance then you might like to redirect the user once they reach the home page to a maintenance notification page. To do so, there is a function in PHP could do the job. It is the header() function and the way to for redirecting a page is like this:

I have created a PHP file named “redirect.php”:

1
2
3
<?php
header('Location: http://www.phpsuperblog.com');
?>

In the case above, the header function is called to redirect the page “http://www.phpsuperblog.com” when that page “redirect.php” loads.

Replace the URL with the one whatever you like to redirect to.

Not what you want? Try a Search

Add A Comment

*