Redirect to another web page using PHP

Home -> Programming -> Web -> PHP

47572 views

From the computer of: qmchenry (339 recipes)
Created: Jun 09, 2004


0 comments:
View all comments

Add a comment

Add to:
Add to stumbleuponAdd to del.icio.usDigg itAdd to FURL

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 http://www.tech-recipes.com/index.php). 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.

Subscribe to the Tech-Recipes Newsletter

You can get tips like this delivered in your email every week!

Enter your Email

We will never, ever sell your email address or spam you.





Related recipes:

  PHP: Password Protect Your pages.
  PHP: Read a browser cookie value
  Solve PHP error: Cannot modify header information - headers already sent
  PHP: Set or create a simple browser cookie with setcookie
  PHP: Upload Files to the server
  PHP: Generate Dynamic Images from Text
  PHP syntax: variable assignments
  PHP syntax: comments
  PHP: Create a File on your Server
  PHP conditional syntax: less than

 

Sponsored links

 

Login

Nickname

Password

Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.