As you know, what mod_rewrite basically does is to translate an input string (the URL typed by your
visitor) to another string (a URL that can be processed by your PHP scripts). In this exercise you make it
This exercise, as all the other exercises in this book, assumes that you’ve installed
Apache and PHP as shown in Chapter 1.
Please visit Jaimie Sirovich’s web page dedicated to this book —
— for updates and additional
information regarding the following code.
httpd.conf versus .htaccess
There are also some subtle differences in the way Apache handles rules for mod_rewrite
. If for any reason you prefer using
need to take this into consideration while going through the exercises:
You should place your rewrite rules inside the
file instead of
When working with
, the slash (
) that follows the domain
name in a URL is considered to be part of the URL.
In the next exercise, you are presented this URL rewriting code:
RewriteRule ^my-super-product\.html$ /product.php?product_id=123
, the rule would need to contain an extra slash:
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 50