PHP: Making Page Redirects Permanent

PHP: Making Page Redirects Permanent

I was looking for a good way of redirecting a page I had to move and found this from Dylan at WeDefy dot com. Dylan said that HTTP status codes changes the way browsers (and robots) handle redirects, so when using header(Location:) it’s a good idea to set the status code.

<?php
// 301 Moved Permanently
header("Location: /foo.php",TRUE,301);

// 302 Found
header("Location: /foo.php",TRUE,302);
header("Location: /foo.php");

// 303 See Other
header("Location: /foo.php",TRUE,303);

// 307 Temporary Redirect
header("Location: /foo.php",TRUE,307);
?>

I went with the 301 option, but Dylan goes on to say: Browsers typically re-request a 307 page every time, cache a 302 page for the session, and cache a 301 page for longer, or even indefinitely. Search engines typically transfer “page rank” to the new location for 301 redirects, but not for 302, 303 or 307.

If the status code is not specified, header(‘Location:’) defaults to 302.

JavaScript: Using a Frame Enforcer as a Redirect

JavaScript: Using a Frame Enforcer as a Redirect

Learning by doing and we’re off again!

Today I had to find a way of stopping the competition between our old site willowsystem.com and the new one Willow4U.com. I also transferred the description of the Willow Treatment System form the old to the new, as I didn’t think the new one had the clout of the old one. You can take a look here and let me know what you think?

So back to the problem
There are so may redirect scripts out there, again I had no idea which to use. I wanted to make it automatic, but for the people that get there from Google & co. with scripts turned off (I’m not even convinced that people do that anymore, or know that they can?) the is a logo and a normal link, something like this:

improving lives since 1986

The page you requested has moved!
An automatic redirection is unfortunately not possible.
Please use the link below. Please update your bookmarks / favorites in your browser.
http://www.willow4u.com/willow_treatment.php

We apologize for the inconvenience.
Paul E Harrison your Webmaster Willow4U.com

I added this in the head:

<meta name="robots" content="noindex,follow">

For the automatic bit I used this script:

<script language="JavaScript" type="text/javascript">
<!-- //Hide script from older browsers
//Set redirect page<br>
var url = "http://www.willow4u.com/willow_treatment.php"; //Should this page be in frames?
// y for yes and n for no
frameEnforcer("y");
function frameEnforcer(frames) {
if (frames == 'y'){
if (self.parent.frames.length == 0){
self.parent.location = url;
}
}
else if (frames == 'n'){
if (self.parent.frames.length != 0){                self.parent.location=url;
}
}
}
// end hiding contents -->
</script>

Now I know if there’s a better way you’ll tell me…

Making Willow4U
I HOPE!!!!!

by: Paul E. Harrison
Webmaster Willow4U.com

Lets be friends on FacebookLets be friends on Google+Lets be friends on Twitter