![]() |
|
|
| Subject:
using PHP to redirect a web page with a 301 status code
Category: Computers > Internet Asked by: coppedahl-ga List Price: $25.00 |
Posted:
20 Aug 2006 10:26 PDT
Expires: 19 Sep 2006 10:26 PDT Question ID: 757868 |
I need to generate a permanent redirect using HTTP 301. I am running
the Xitami web server with PHP version 4.4.2. Here is the script I am
using:
<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.oppedahl.com/index2.htm");
exit();
?>
But when I view the server response using
http://www.rexswain.com/cgi-bin/httpview.cgi , I get a "302 found"
when I really wanted "301 moved permanently" code.
The PHP documentation says two things I don't really understand. It says:
The second special case is the "Location:" header. Not only does it
send this header back to the browser, but it also returns a REDIRECT
(302) status code to the browser unless some 3xx status code has
already been set.
But I surely think I had previously already set a 301 status code.
The PHP documentation also says:
Note: Since PHP 4.4.2 and PHP 5.1.2 this function prevents more than
one header to be sent at once as a protection against header injection
attacks.
Which makes me wonder if my two-line PHP script is doomed never to
execute both lines. | |
| |
|
|
| There is no answer at this time. |
|
| There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |