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
https://forums.phpfreaks.com/topic/195143-php-page-redirection/
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

<?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.

<?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

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...)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.