Re: Question about HTTP 301 permanent redirects
| From: | Jochem Maas | Date: | Tue, 28 Jun 2005 09:01:54 +0000 |
| Subject: | Re: Question about HTTP 301 permanent redirects | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-217743@lists.php.net to get a copy of this message | ||
Jasper Bryant-Greene wrote:
Kevin L'Huillier wrote:I don't think the server itself is coded in php - and regardless of the technology used to deliver a site, php is not required to output a HTTP header - although it does make it easy :-)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?
and you can't ber bothered to read properly either, you reuse the other guys' code but you fail to see it has blatant typos in it - given your resounding "WRONG" I figure the least you could do it post something that isn't. besides if you ask me, saying things like "please only reply if you know how" is: a, pretty implicit when asking a question. b, shortsighted c, a little rude d, the OP has the title 'Dr.' - now I have friends who are doctors in various fields, and I expect everyone of them to be able to use google, ... hint hint. thankfully Jasper 'knows how'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);^ typo! (also where is $i coming from?)
header('HTTP/1.1 301 Moved Permanently');also consider that using 'Status' may be better or possibly both to cover you bases, e.g.: <?php header("HTTP/1.1 301 Moved Permanently"); header("Status: 301 Moved Permanently"); ?>
header('Location: ' . $url); Jasper