Jump to content

php page redirection


pklover

Recommended Posts

can any help me ? i want to use php for page redirection like iframe

 

<iframe src="www.mydoamin.com/page.php" width="500" height="450">

</iframe>

 

if this iframe use in my site redirect to www.mydoamin.com/mysitepage.html

 

if this iframe any other use than redirect to

www.mydoamin.com/sorry.html

Link to comment
Share on other sites

<?php

header('Location: http://www.yoursite.com/');

?>

 

Taken from

-

http://php.net/manual/en/function.header.php

 

Thats ok if your headers havent been sent, othwise youll need javascript:

 

function redirect( $url ){
if (! headers_sent( ) ){

header( "Location: ".$url );
exit( 0 );
}
echo "<script language=Javascript>document.location.href='".$url."';</script>";
exit( 0 );
} 

redirect('http://www.yoursite.com/'); //redirect to any url

Link to comment
Share on other sites

<?php

header('Location: http://www.yoursite.com/');

?>

 

Taken from

-

http://php.net/manual/en/function.header.php

 

Thats ok if your headers havent been sent, othwise youll need javascript:

 

function redirect( $url ){
if (! headers_sent( ) ){

header( "Location: ".$url );
exit( 0 );
}
echo "<script language=Javascript>document.location.href='".$url."';</script>";
exit( 0 );
} 

redirect('http://www.yoursite.com/'); //redirect to any url

 

Even better - code properly, so all of your PHP processing happens before headers are sent.

Link to comment
Share on other sites

<?php

header('Location: http://www.yoursite.com/');

?>

 

Taken from

-

http://php.net/manual/en/function.header.php

 

Thats ok if your headers havent been sent, othwise youll need javascript:

 

function redirect( $url ){
if (! headers_sent( ) ){

header( "Location: ".$url );
exit( 0 );
}
echo "<script language=Javascript>document.location.href='".$url."';</script>";
exit( 0 );
} 

redirect('http://www.yoursite.com/'); //redirect to any url

actually your wrong. Location can be called even after the headers have been sent

Link to comment
Share on other sites

actually your wrong. Location can be called even after the headers have been sent

 

Actually you're wrong:

 

You can't add any more header lines using the header() function once the header block has already been sent.

 

http://us.php.net/manual/en/function.headers-sent.php

 

i.e. Once the headers have been sent, manually or from the server, you aren't allowed to send anymore, unless you do something manually with the buffer, like ob_clean() or flush() (i believe...)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.