The Search() method of the business tier returns an array that contains, apart from the list of returned products,
the list of words that were used for searching and the list of words that were ignored (words shorter than a predefined
number of characters). These details are shown to the visitor.
The novelty in this exercise is in the .htaccess rules. As you know, when the visitor submits a new search query,
the request is redirected to a keyword-rich URL that represents the results page that your visitors can bookmark.
The rewrite rules read the keyword-rich URLs to their dynamic counterparts:
# Redirect search results
RewriteRule ^search-results/find-(.*)/all-words-(on|off)/page-([0-9]+)/?$
index.php?SearchResults&SearchString=$1&AllWords=$2&Page=$3 [L]
RewriteRule ^search-results/find-?(.*)/all-words-(on|off)/?$
index.php?SearchResults&SearchString=$1&AllWords=$2&Page=1 [L]
The first of these rules matches paged search results URLs, and the second rule matches nonpaged search
results URLs.
Summary
In this chapter, you implemented the search functionality of TShirtShop by using the full-text
searching functionality of MySQL. The search mechanism integrated very well with the current
web site structure and the paging functionality built in Chapter 4. The most interesting new
detail you learned in this chapter was about performing full-text searches with MySQL.
Pages:
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362