Rewriting Keyword-Rich URLs

rules for your .htaccess file

Modify the .htaccessfile in your seophpfolder like this:
RewriteEngine On
# Rewrite numeric URLs
RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$ i
/product.php?category_id=$1&product_id=$2 [L]

# Rewrite keyword-rich URLs
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$ i
/product.php?category_id=$1&product_id=$2 [L]

Load http://test.example.com/Products/Tools-C5/Super-Drill-P9.html

The new rule matches URLs that start with the string Products/, then contain a number of zero or more
characters (.*) followed by –C. This is expressed by ^Products/.*-C. The next characters must be one
or more digits, which as a whole are saved to the $1variable, because the expression is written between
parentheses — ([0-9]+). This first variable in the URL, $1, is the category ID

After the category ID, the URL must contain a slash, then zero or more characters (.*), then -P, as expressed
by /.*-P. Afterward, another captured group follows, to extract the ID of the product, ([0-9]+), which
becomes the $2variable. The final bit of the regular expression, \.html$, specifies the URL needs to end
in .html.
The two extracted values, $1and $2, are used to create the new URL, /product.php?category_id=
$1&product_id=$2. Figure 3-13 describes the process visually.