Redirect to another page in PHP code example

Example 1: php redirect

//PHP redirect
header("Location: https://www.codegrepper.com/my-redirect-page.php");
die();

Example 2: how to redirect with php

<?php
  header("Location: (redirect url)");
?>

Example 3: php redirect to page

header("Location: /");
exit();

Example 4: header location in php

<?php
/*
	This will redirect  to facebook.com
*/
$url = "https://facebook.com.com";
header("Location: $url");  
exit;
?>

Example 5: how to redirect to another page in php

<?php header("Location: anotherDirectory/anotherFile.php"); ?>

Example 6: redirect to site php

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

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

Tags:

Php Example