JavaScript Editor Ajax software     Free javascripts 



Main Page

4.
Load
http://seophp.example.com/Products/C5/P99.html
, and expect to get the same
output as with the previous request, as shown in Figure 3-10.
Figure 3-10
In this example you started by modifying
product.php
to accept product URLs that accept a product
ID and a category ID. Then you added URL rewriting support for URLs with two numeric parameters.
You created a rewriting rule to your
.htaccess
file, which handles URLs with two parameters:
RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$
i
/product.php?category_id=$1&product_id=$2 [L]
The rule looks a bit more complicated, but if you look carefully, you’ll see that it’s not so different from
the rule handling URLs with a single parameter. The rewriting rule has now two parameters —
$1
is the
number that comes after
Products/C
, and is defined by
([0-9]*
), and the second parameter,
$2
, is
the number that comes after
/P
.
Figure 3-11 is a visual representation of how this rewrite rule matches the incoming link.
The result is that you now delegate any URL that looks like
Products/C
m
/P
n
.html
to
product.php?category_id=
m
&product_id=
n
.
Figure 3-11
Client requests URL
http://seophp.example.com/Products/C5/P99.html
^Products/C([0–9]*)/P([0–9]*)\.html$
/product.php?category_id=$1&product_id=$2
PHP script executes
/product.php?category_id=5&product_id=99
mod_rewrite
translates request
63
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 63


JavaScript Editor Ajax software     Free javascripts 
Bitcoin Dice - Crypto Casino . paperhelp expert