PHP code to redirect a page

Posted in: PHP 1 Comment

You can set redirection of a page to any other url using a simple php code. In below code I will redirect to www.google.com

header("Location: http://www.google.com");

If you want to set a timer with a message like “You will be redirected to www.google.com in 5 seconds” use below code.

header("Refresh: 5; url=http://www.google.com"); 
echo "You will be redirected to www.google.com in 5 seconds."; 


About the Author

Name: Ravi Shekhar
I love learning and sharing web stuffs.

Share this post

Twitter Facebook Google Buzz Digg StumbleUpon Delicious Technorati

1 Comment to "PHP code to redirect a page"

Add Comments (+)
  1. Thanks for providing the basic redirection code. I somehow hate this coz i always go wrong with redirection problems. Guess the code might just help me overcome some of the issues.

Leave a Reply