RewriteCond TestString CondPattern [flags]
- Defines a condition under which rewriting will take place
- backreferences: %1 to %9: groups; %0: whole matched string
- [flags]: 'nocase|NC' (case-insensitive); 'ornext|OR'; 'novary|NV' (no vary)
RewriteRule Pattern Substitution [flags]
- Defines rules for the rewriting engine
- if Substitution is - (dash), no replacement
- [flags]:
- last|L: Stop the rewriting process immediately and don't apply any more rules
- redirect|R[=code]: Forces an external redirect, optionally with the specified HTTP status code.
- QSA: Appends any query string from the original request URL to any query string created in the rewrite target. Example:
RewriteRule "/pages/(.+)" "/page.php?page=$1" [QSA]
With the [QSA] flag, a request for /pages/123?one=two will be mapped to /page.php?page=123&one=two. Without the [QSA] flag, that same request will be mapped to /page.php?page=123 - that is, the existing query string will be discarded.
ref: http://httpd.apache.org/docs/current/mod/mod_rewrite.html