header in php to redirect code example

Example 1: php redirect

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

Example 2: php 301 redirect

<?php // Permanent 301 Redirect via PHP
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: http://domain.tld/new/location/");
	exit();
?>

Example 3: php header redirect

< ?php header("Location: http://www.redirect.to.url.com/"); ?>

Example 4: php header redirect with parameters

$id_car = '2';
Header("Location: formUpdateCar.php?car=".$id_car);

Tags:

Php Example