Ajax software
Free javascripts
↑
Main Page
The second argument of
RewriteRule
isn’t written using the regular expressions language. Indeed,
it doesn’t need to, because it’s not meant to match anything. Instead, it simply supplies the form of the
rewritten URL. The only part with a special significance here is the
$1
variable, whose value is extracted
from the expression between parentheses of the first argument of
RewriteRule
.
As you can see, this rule does indeed rewrite any request for a URL that ends with
Products/P
n
.html
to
product.php?productID=
n
, which can be executed by the
product.php
script you wrote earlier.
At the end of a rewrite rule you can also add special flags for the new URL by appending one or more
flag arguments. These arguments are specific the
RewriteRule
command, and not to regular expres-
sions in general. Table 3-4 lists the possible
RewriteRule
arguments. These rewrite flags must always
be placed in square brackets at the end of an individual rule.
Table 3-4
RewriteRule
Option
Significance Description
R
Redirect
Sends an HTTP redirect
F
Forbidden Forbids access to the URL
G
Gone
Marks the URL as gone
P
Proxy
Passes the URL to mod_proxy
L
Last
Stops processing further rules
N
Next
Starts processing again from the first rule, but using the current
rewritten URL
C
Chain
Links the current rule with the following one
T
Ty pe
Forces the mentioned MIME type
NS
Nosubreq The rule applies only if no internal sub-request is performed
NC
Nocase
URL matching is case-insensitive
QSA
Qsappend Appends a query string part to the new URL instead of replacing it
PT
Passthrough Passes the rewritten URL to another Apache module for further
processing
S
Skip
Skips the next rule
E
Env
Sets an environment variable
59
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 59
Ajax software
Free javascripts
→ R7