the individual product pages. These URLs are “hackable,” in that the products will be placed in an
intuitive-looking directory structure. Users can intuitively modify such URLs to navigate the site.
Rewriting Keyword-Rich URLs
file in your
folder like this:
# Rewrite numeric URLs
# Rewrite keyword-rich URLs
voila, you should get the result that’s shown in Figure 3-12.
You currently have two rules in your
file, and they are working beautifully!
The new rule matches URLs that start with the string
, then contain a number of zero or more
) followed by
. This is expressed by
. The next characters must be one
or more digits, which as a whole are saved to the
variable, because the expression is written between
. This first variable in the URL,
, is the category ID.
After the category ID, the URL must contain a slash, then zero or more characters (
, as expressed
. Afterward, another captured group follows, to extract the ID of the product,
variable. The final bit of the regular expression,
, specifies the URL needs to end
The two extracted values,
, are used to create the new URL,
. Figure 3-13 describes the process visually.
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 65