Ajax software
Free javascripts
↑
Main Page
Here you use a regular expression to check if the URL ends with the aforementioned file names. You use
the
preg_match()
function, and instruct it to store any characters that precede the file name by placing
.*
within parentheses —
(.*)
. These characters, now stored in
$captures[1]
, will be the location you want
to redirect to.
If you have a match, you then perform the 301 redirect:
{
// perform a 301 redirect to the new URL
header(‘HTTP/1.1 301 Moved Permanently’);
header(‘Location: ‘ . $captures[1]);
}
Other Types of Redirects
Although there are other types of redirects, such as meta refresh and JavaScript redirects, we do not
generally recommend their use. Spammers have historically abused them, and for this reason their use
is almost
always
suspect. It is recommended that a meta refresh is never used with a delay of less than
10 seconds. A typical meta refresh is illustrated here:
<!-- Redirect to SEO Egghead in 10 seconds -->
<meta http-equiv=”refresh” content=”10;url=http://www.seoegghead.com/“>
We do not recommend using JavaScript-based redirects at all. If discovered, it will most likely result in
some sort of penalty.
Summary
This chapter has illustrated that a fundamental understanding of relevant HTTP status codes is vital to
the search engine marketer. Business decisions dictate that pages move, domains change, or that content
is removed. Informing the search engine of these decisions using these status codes can avert a very
costly “misunderstanding.”
94
Chapter 4: Content Relocation and HTTP Status Codes
c04.qxd:c04 10:40 94
Ajax software
Free javascripts
→