JavaScript Editor Ajax software     Free javascripts 



Main Page

Except for the new
R
option at the end, there’s nothing new for you here — but that option represents
an important difference! With or without the
R
option, the visitor would end up transparently seeing
the content provided by
bar.php
. However, when redirection is used, the user’s web client actually
makes two calls to the web server. First it asks for
foo.php
; as a response, it gets a 301 redirect code in
the HTTP header, indicating
bar.php
as the new location. Then the web client requests
bar.php
, and
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
header()
function. If you want
foo.php
to do
a 301 redirect to
bar.php
, your
foo.php
should look like this:
<?php
header(‘HTTP/1.1 301 Moved Permanently’);
header(‘Location: http://www.example.com/bar.php’);
?>
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:
http://seophp.example.com/Products/SEO-Toolbox-C6/Link-Juice-P31.html
and
http://seophp.example.com/product.php?category_id=6&product_id=31
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
indexed.
Alright, we’re sure you’re eager to write some code!
When just the
Location
header is mentioned without explicitly mentioning the
status code, a 302 temporary redirect is implied. Keep this in mind.
85
Chapter 4: Content Relocation and HTTP Status Codes
c04.qxd:c04 10:40 85


JavaScript Editor Ajax software     Free javascripts 
Bitcoin Gambling - The Original Crypto Dice Game . paperhelp.org log in