Thu 6 Mar 2008
<?
$URLTOSENDTO="http://www.unfocusedbrain.com/site/";
header("Expires: Wed, 15 Aug 1984 20:30:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache");
header(”Location: $URLTOSENDTO”);
?>
<a href=”site/”>Enter Here</a>
March 6th, 2008 at 10:33 pm
Is this the correct way to do location redirects? In the past I have not used this method and simply done:
and it worked fine. I thought that apache handled the headers and everything.
March 7th, 2008 at 11:31 am
All that is really needed is the location line. I added the other stuff to make sure that it doesn’t get cached. Its not all necessary but I just want to be sure.
Here is what the headers look like w/ the above code:
$ lynx -head -dump http://www.unfocusedbrain.com/
HTTP/1.1 302 Moved TemporarilyDate: Fri, 07 Mar 2008 17:30:07 GMT
Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8g DAV/2 mod_auth_passthr
ough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.5
Expires: Wed, 15 Aug 1984 20:30:00 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Last-Modified: Fri, 07 Mar 2008 17:30:07 GMT
Location: http://www.unfocusedbrain.com/site/
Connection: close
Content-Type: text/html
Here is what the headers look like without all the extra stuff and just the location header:
$ lynx -head -dump http://www.unfocusedbrain.com/test.php
HTTP/1.1 302 Moved Temporarily
Date: Fri, 07 Mar 2008 17:36:30 GMT
Server: Apache/2.2.6 (Unix) mod_ssl/2.2.6 OpenSSL/0.9.8g DAV/2 mod_auth_passthr
ough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.5
Location: http://www.unfocusedbrain.com/site/
Connection: close
Content-Type: text/html