JavaScript Editor Ajax software     Free javascripts 



Main Page

For rewriting two parameters, the rule would be a bit longer, but not much more complex:
RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$
i
/product.php?category_id=$1&product_id=$2 [L]
Go ahead and put this to work in a quick exercise.
Rewriting Numeric URLs
1.
In your
seophp
folder, modify the
product.php
script that you created earlier like this:
<?php
// display product details
echo ‘You have selected product #‘ . $_GET[‘product_id’] .
‘ from category #‘ . $_GET[‘category_id’];
?>
2.
Test your script by loading
http://seophp.example.com/product.php?category_
id=5&product_id=99
in your web browser. You should get the expected output as shown
in Figure 3-9.
Figure 3-9
3.
Change the current rewriting rule in your
.htaccess
file as shown in the following code. Also
remove any old rules, because they wouldn’t work well with the new
product.php
script,
which receives two parameters now.
RewriteEngine On
# Rewrite numeric URLs
RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$
i
/product.php?category_id=$1&product_id=$2 [L]
Note that the entire
RewriteRule
command and its parameters must be written on a single line in
your
.htaccess
file. If you split it in two lines as printed in the book, you’ll get a 500 error from the
web server when trying to load scripts from that folder.
62
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 62


JavaScript Editor Ajax software     Free javascripts 
Bitcoin Dice Site