Load TShirtShop, and notice the new links. In Figure 7-3, the link to the Visit the Zoo product,
http://localhost/tshirtshop/visit-the-zoo-p36/, is visible in Internet Explorer??™s status bar.
Figure 7-3. Testing dynamically generated keyword-rich URLs
How It Works: Generating Keyword-Rich URLs
In this exercise, you modified the ToIndex(), ToDepartment(), ToCategory(), and ToProduct() methods
of the Link class to build keyword-rich URLs instead of dynamic URLs. To support this functionality you created
infrastructure code (business tier methods and database stored procedures) that retrieves the names of departments,
products, and categories from the database.
You also implemented a method named CleanUrlText(), which uses regular expressions to replace the characters
that we don??™t want to include in URLs with dashes. This method transforms a string such as ???Visit the Zoo??? to
a URL-friendly string such as ???visit-the-zoo.???
Make sure all the links in your site are now search engine-friendly, and let??™s move on to the next task for this
chapter.
CHAPTER 7 ?– SEARCH ENGINE OPTIMIZATION 202
URL Correction with 301 Redirects
One potential problem with our site now is that the same page can be reached using many
different links. Take, for example, the following URLs:
http://localhost/tshirtshop/nature-d2/
http://localhost/tshirtshop/TYPO-d2/
Because content is retrieved based on the hidden ID in the links, which in these examples
is 2, both links would load the Nature department, whose correct link is http://localhost/
tshirtshop/nature-d2/.
Pages:
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313