Quote:
Originally Posted by Jennifer Dallas
The web developers also tell me this is just caused by a stale cache but we are not convinced.
Many thanks
Jennifer
|
I would check with your developers to make sure that they specified the new location. I.e.
Simply throwing out a 301 response is not enough, because you need to inform where the page was moved as well, this is done like below.
Code:
header("HTTP/1.1 301 Moved Permanently");
header('Location: ' . $Location['New']);
This would ensure that you wouldn't lose visitors from those outdated URLs. You can then remove the redirect, when the traffic on those URLs had decreased.
The way to check which URL was requested, is to use something like below.
Code:
$requested_path = $_SERVER['REQUEST_URI'];
This can be used in an if statement, to throw out the correct response code, and relevant redirect. I.e.
Code:
if (preg_match("/^\/([A-Za-z]+)\/([0-9]+)\/$/D", $requested_path, $match)) {
header("HTTP/1.1 301 Moved Permanently");
header('Location: ' . $Domain['Name'] . $match[1] . '/' . $UrlConstruct . '_' . $match[2] . '.html');
}
The above is an example from one of my own websites, just to show that you can use regular expressions, to match old URL patterns. The pattern would match urls like "/Tutorials/xx/", and redirect it to the optimized version, where "xx" is the unique PostID. You can include else if statements to match other patterns.