Redirect to a page or file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
conthox
Forum Commoner
Posts: 39
Joined: Tue Jun 25, 2002 1:44 pm
Location: Sweden

Redirect to a page or file

Post by conthox »

How do i redirect a visitor to another page or file with PHP script :?:
Patriot
Forum Commoner
Posts: 34
Joined: Tue Jun 18, 2002 1:36 pm

Post by Patriot »

try this:
<?php
header("Location: http://www.yoursite");
?>

if you want, you can use variables:

<?php
header("Location: $site");
?>
(go to http://yoursite.com/yourpage.php?site=h ... cation.com

remember:
do not print or write anything before the header tag!

this would not work:

<?php
print "hi!"
header("Location: $site");
?>
Post Reply