How do I send HTTP headers with PHP?
Here is an example of using header to re-direct to a different webpage:
<?php
header("Location: http://www.php-questions.com");
?>
There are two mistakes that everyone makes with header the first time they use it so since we're feeling nice, we'll tell you up front to stop some head scratching.
First, the header command must be called before anything is sent to the web browser, otherwise a nice error message will occur.
Second, you'll want to stop execution of the script after the header call, so be sure to include exit; directly underneath. We just saved you a whole load of hassle!
More website PHP Questions
How to find a domain name for an IP address?How do I find a visitors IP address?
How do I display todays date on my website?
How can I find out where a site visitor comes from?
How do I perform a 301 redirect with PHP?