note 78470 added to function.header

From: Date: Sat, 13 Oct 2007 15:17:37 +0000
Subject: note 78470 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-131365@lists.php.net to get a copy of this message
A quick way to make redirects permanent or temporary is to make use of the $http_response_code parameter in header(). <?php // 301 Moved Permanently header("Location: /foo.php",TRUE,301); // 302 Found header("Location: /foo.php",TRUE,302); header("Location: /foo.php"); // 303 See Other header("Location: /foo.php",TRUE,303); // 307 Temporary Redirect header("Location: /foo.php",TRUE,307); ?> The HTTP status code changes the way browsers and robots handle redirects, so if you are using header(Location:) it's a good idea to set the status code at the same time. Browsers typically re-request a 307 page every time, cache a 302 page for the session, and cache a 301 page for longer, or even indefinitely. Search engines typically transfer "page rank" to the new location for 301 redirects, but not for 302, 303 or 307. If the status code is not specified, header('Location:') defaults to 302. ---- Server IP: 216.235.15.211 Probable Submitter: 142.162.150.1 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/78470 Del: integrated -- https://master.php.net/note/delete/78470/integrated Del: useless -- https://master.php.net/note/delete/78470/useless Del: bad code -- https://master.php.net/note/delete/78470/bad+code Del: spam -- https://master.php.net/note/delete/78470/spam Del: non-english -- https://master.php.net/note/delete/78470/non-english Del: in docs -- https://master.php.net/note/delete/78470/in+docs Del: other reasons-- https://master.php.net/note/delete/78470 Reject -- https://master.php.net/note/reject/78470 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131365) next »