3

I want to rewrite URLs while still allowing multiple optional Query Strings.

For example, I know I can do this:

RewriteCond %{QUERY_STRING} ^page=(\d+)$
RewriteRule ^products/?$ products.php

Is it possible to allow more query strings to be passed so I could use something like products/?page=1&foo=bar and so on?

Thanks.

Edit: What I wanted was just the [QSA] at the end of the rule. Works like I expected.

Ricky
  • 31
  • 2

1 Answers1

1

You can do:

RewriteCond %{QUERY_STRING} ^page=[0-9]*&foo=bar$
RewriteRule ^products/?$ products.php [L]

Or simply rewrite your condition like this:

RewriteCond %{QUERY_STRING} (^|&)page=[0-9]*(&|$)
RewriteRule ^products/?$ products.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thanks for the help, but not exactly what I wanted. I've just found out that I can add [QSA] at the end of the rule and it works as I expected. Thanks anyway! – Ricky Sep 15 '11 at 15:02