Except for the new
option at the end, there’s nothing new for you here — but that option represents
an important difference! With or without the
option, the visitor would end up transparently seeing
the content provided by
. However, when redirection is used, the user’s web client actually
makes two calls to the web server. First it asks for
; as a response, it gets a 301 redirect code in
the HTTP header, indicating
as the new location. Then the web client requests
informs the user that a new URL has been loaded by updating the URL displayed in the address bar.
In PHP, you redirect by adding HTTP headers using the
function. If you want
a 301 redirect to
should look like this:
header(‘HTTP/1.1 301 Moved Permanently’);
In practice, when a site redesign involves changing URLs, the webmaster should at least 301 redirect the
most important URLs to their new counterparts. Otherwise link equity will be lost.
Using a series of 301 redirects mitigates this problem. If your site is already indexed by search engines,
you need to systematically rewrite old URLs to new URLs.
Using Redirects to Change File Names
In the exercise that follows you update the product pages you created in Chapter 3 to redirect all
the dynamic URLs to their keyword-rich versions. Currently, the same content can be retrieved using
both dynamic URLs and keyword-rich URLs (see Figure 3-9 and Figure 3-12 from Chapter 3); the follow-
ing two links would get to the same content:
To avoid any problems that can result from two links generating this duplicate content, make sure that
the visitor is always redirected to the proper keyword-rich URL, if a different URL was used. This is crit-
ical during a migration to such URLs on a preexisting web site, because the old URLs will be definitely
Alright, we’re sure you’re eager to write some code!
When just the
header is mentioned without explicitly mentioning the
status code, a 302 temporary redirect is implied. Keep this in mind.
Chapter 4: Content Relocation and HTTP Status Codes
c04.qxd:c04 10:40 85
Bitcoin Gambling - The Original Crypto Dice Game . paperhelp.org log in