How to Place Redirect Code on PHP
- 1). Open the text editor Notepad, and create a page called index.php.
- 2). Add the following code:
<?php
/* Redirect to a different page */
header("Location: http://www.google.com");
exit;
?>
This must be placed at the top of the page before any other output code for the page, or this command will be ignored. Replace the URL listed with the address of another Web site. That redirects visitors to the new site. - 3). Save the index.php page, and run the page in a browser. Once you open the index.php page, you will be redirected to the location entered in the previous step.