How to do redirect in php by Bally Chohan?

March 2nd, 2010

How to do redirect in php by Bally Chohan ?

Redirection is  act of setting a new direction; The automated process of taking a user to a location other than the one selected.

There are two ways to redirect old page to new page:

1. .htaccess

2. Php code

  1. <?php
    header( ‘Location: http://www.ballychohan.info‘ ) ;
    ?>

    Change the code on the redirect page to be simply this. You need to replace the URL above with the URL you wish to direct to.

2. Be sure that you do not have any text sent to the browser before this, or it will not work. Your safest bet is to simply remove all content from the page but the redirect code.

<html>
<?php
//this will NOT work, the browser received the HTML tag before the script
header( ‘Location: http://www.ballychohan.info” ) ;
?>

Categories: PHP Tutorials

Leave a comment

Leave a comment

Feed

http://www.ballychohan.info / How to do redirect in php by Bally Chohan?

FaceBook LinkedIn Twitter Twitter