Ajax software
Free javascripts
↑
Main Page
</li>
</ul>
</body>
</html>
5.
You’re making use of the
product.php
file you created in the previous exercise. Here’s its code
again for your reference:
<?php
// display product details
echo ‘You have selected product #‘ . $_GET[‘product_id’] .
‘ from category #‘ . $_GET[‘category_id’];
?>
6.
Add one last rule to your
.htaccess
file:
RewriteEngine On
# Rewrite numeric URLs
RewriteRule ^Products/C([0-9]*)/P([0-9]*)\.html$
/product.php?category_id=$1&product_id=$2 [L]
# Rewrite keyword-rich URLs
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$
/product.php?category_id=$1&product_id=$2 [L]
# Rewrite catalog.html
RewriteRule ^catalog.html$ /catalog.php [L]
7.
Load
http://seophp.example.com/catalog.html
in your web browser. You should be
shown a page like the one shown in Figure 3-14.
8.
Click one of the links, and ensure the rewriting correctly loads the
product.php
script as
shown in Figure 3-15.
9.
Just for the fun of it, or if you want to refresh your memory about how the
product.php
script
works, load
http://seophp.example.com/product.php?category_id=6&product_id=31
.
You should get the same output that’s shown in Figure 3-15, but this time through a dynamic URL.
Figure 3-14
69
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 69
Ajax software
Free javascripts
→ R7