Preparing Your New Site for Structural Changes - Proper Redirect - Redirection with 301 Code
(Page 4 of 6 )
In our previous version of redirect.php we employed the simple location header to redirect our visitor to the new location. We saw that this did not accomplish what we wanted as it gives no indication that the content has been moved PERMANENTLY. To make the move permanent we must use the 301 status code. The following is redirect.php with the 301 header added:
<?
//redirect.php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/");
?>
Below is a snippet from the actual exchange that took place when the server fulfilled my request for /redirect.php after the addition of the 301 header
HTTP/1.1 301 Moved Permanently\r\n
Date: Tue, 23 Dec 2003 20:58:52 GMT\r\n
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_jk/1.2.0 mod_perl/1.26 PHP/4.2.2 FrontPage/5.0.2 mod_ssl/2.8.12 OpenSSL/0.9.6b\r\n
X-Powered-By: PHP/4.2.2\r\n
Location: http://www.example.com/\r\n
Keep-Alive: timeout=15, max=100\r\n
Connection: Keep-Alive\r\n
Transfer-Encoding: chunked\r\n
Content-Type: text/html\r\n
\r\n
Next: Moving Pages >>
More Search Optimization Articles
More By Bill Sterzenbach