Re: Question about HTTP 301 permanent redirects

From: Date: Tue, 28 Jun 2005 06:17:33 +0000
Subject: Re: Question about HTTP 301 permanent redirects
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-217741@lists.php.net to get a copy of this message
Kevin L'Huillier wrote: > On 27/06/05, Dr. Brad Lustick <sales@backbenimble.com> wrote: >>I'm a novice trying to understand the exact construction of code for doing an HTTP 301 >>permanent redirect for a server >>coded in PHP. Could someone please tell me how I would handle the following example? > > In your case you might want to do something like: > > $article = $_REQUEST['i']; > // some validation of $article if necessary > $url = sprintf('/services.php/%s'. $i); > header('Location: ' . $url); WRONG. He specifically said please only reply if you know how. Obviously you do not. To do an HTTP/1.1 *301 Permanent Redirect* not a *302 Found* Redirect as you described, that code would need to be altered to: $article = $_REQUEST['i']; // some validation of $article if necessary $url = sprintf('/services.php/%s'. $i); header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url); Jasper

« previous php.general (#217741) next »