Redirection uisng PHP Headers

by Rekha 2010-02-09 12:25:08

We will be using the PHP header function to send the HTTP headers required to perform the redirect. Note that the header function must must be called before any other output in your PHP script.

Location Header

The Location header is used to redirect the user agent (i.e. web browser, search engine spider, etc.) to some other URL. The following PHP code can be used to send the Location header:

<?php
header("Location: http://www.xxx.com/newpage.php");
exit;
?>


When the PHP header function sends this header, it will also send the temporary redirect (302) status code. The temporary redirect status code tells the user agent to continue to use the original URL.

Tagged in:

871
like
0
dislike
0
mail
flag

You must LOGIN to add comments