Ajax software
Free javascripts
↑
Main Page
Then you read the names of the product and the category from your fictional database:
// retrieve product and category names from fictional database
$product_name = $GLOBALS[‘products’][$product_id];
$category_name = $GLOBALS[‘categories’][$category_id];
The fictional database consists of two global associative arrays, associating IDs with names. These are defined
in
config.inc.php
, and simulate a real database of products. This example uses associative arrays to keep
things simple. You would need a real database in production scenario, however.
// create a fictional database with products and categories
$GLOBALS[‘products’] = array
(“45” => “Belt Sander”,
“31” => “Link Juice”,
“42” => “AJAX PHP Book”);
$GLOBALS[‘categories’] = array
(“12” => “Carpenter’s Tools”,
“6” => “SEO Toolbox”,
“2” => “Friend’s Shed”);
With this data at hand,
get_proper_category_product_url()
continues by creating the keyword-rich
URL using the
make_category_product_url()
function of the URL factory:
// create keyword-rich URL
$proper_url = make_category_product_url($category_name, $category_id,
$product_name, $product_id);
Finally, the function returns this value:
// redirect to keyword-rich URL if not already there
return $proper_url;
URL Correction
The great advantage with your current keyword-rich URLs is that you aren’t really relying on the product
or category names to find their data, but rather only on their IDs, which are subtly inserted in the URLs.
This works great because the text in the URL can change without disabling it.
One potential problem with these links, though, is that when the text for a product or category name
changes, its link will automatically be changed as well. As you already know, this has the potential to
generate duplicate content problems, and that’s certainly not something that you want!
With your current site, there are an infinite number of variations that lead to the same content. Take
these two “different” links:
http://seophp.example.com/Products/SEO-Toolbox-C6/Link-Juice-P31.html
and
http://seophp.example.com/Products/SEO-Toolbox-C6/New-Link-Juice-With-Vitamin-L-P31
.html
89
Chapter 4: Content Relocation and HTTP Status Codes
c04.qxd:c04 10:40 89
Ajax software
Free javascripts
→ R7