Redirect to another web page using PHP

Posted June 9, 2004 by Quinn McHenry in PHP programming

Last Updated on

Redirection from one web page to another is a handy tool. This recipe describes the syntax that causes the client to redirect to another URL.

The following php script redirects the user to /index.php within the same site:

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

The redirection target can be any suitable URL as could be used in the href parameter of an address tag (such as The header function sends raw header data to the client web browser and in this case sends a 302 status code which instructs the browser to redirect to the given location.


About Quinn McHenry

Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
View more articles by Quinn McHenry

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply