Kevin Wang
0
Q:

php redirect to url

//PHP redirect
header("Location: https://www.codegrepper.com/my-redirect-page.php");
die();
15
< ?php header("Location: http://www.redirect.to.url.com/"); ?>
2
<?php
/*
	This will redirect  to facebook.com
*/
$url = "https://facebook.com.com";
header("Location: $url");  
exit;
?>
2
header("Location: http://example.com/redirect_page.php");
die(); //Force the script to quit, or you would raise an error...
2
header("Location: /");
exit();
1
header("Location: http://example.com/myOtherPage.php");
die();
4

<html>
<?php
/* This will give an error. Note the output
 * above, which is before the header() call */
header('Location: http://www.example.com/');
exit;
?>

0
//Write this in the Controller when working on Laravel.

header('Location: http://www.example.com/');
exit;
1
header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . $location);
0

New to Communities?

Join the community