'qsappend|QSA' (query string append)
This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.
Note: The query string is automatically passed through UNLESS you create a new query string in the redirection which then makes the QSA necessary. Conversely, to kill a query string, create a new (empty) query string with ? and it will NOT be shown in the URI.
but i also need to go to sunrooms main page if the link is just site.com/sunrooms
I pretty much need a way of pagination… and all my rewrite rules right now are /page/productname.html so i have no way of pasing what page was requested to php…
Okay, let me try to restate your “specifications,” if I can:
URIs:
sunrooms/wood/10 to index.php?page=sunrooms&cat=wood&p=10
page/products.html to index.php?page=products
Clearly, there are two formats for your URIs to be using so you need two mod_rewrite block statements to deal with them but do NOT fall into the trap of using (.*) as this garbage collector (lazy regex) will match nothing and EVERYTHING!
If you can ensure that your links are of the forms on the left above, the main difference between the two is the number of pseudo directory levels and the lack of the html extension has been replaced with digits:
RewriteEngine on
# sunrooms/wood/10 to index.php?page=sunrooms&cat=wood&p=10
RewriteRule ^([a-z]+)/([a-z]+)/([0-9]+)$ index.php?page=$1&cat=$2&p=$3 [L]
# page/products.html to index.php?page=products
[I]# What's the page for in the from URI?[/I]
RewriteRule ^([a-z]+)/([a-z]+)\\.html$ index.php?page=$2 [L]
Of course, I’ve required your page and cat to consist only of lowercase characters and the p value to be digits. You can also eliminate the page requirement by making the third atom optional as follows:
Noone will see the empty value for p if it’s missing in the URI but it will not require it to be present.
The point that I’m trying to make is that creating a “specification” before you start your mod_rewrite coding should make the task abundantly clear which makes the coding a trivial exercise.