Forum Moderators: phranque
I have a file called file.php which can contain up to six variables in the query string (a=1&b=2&c=3 etc). I've rewritten the href URLs to the two most important variables, and then the four others in a query string, so a typical URL would look like host.com/a1/b2.htm while with the query string (less common occurances) it would be host.com/a1/b2.htm?c=3&d=4 etc.
I then have the following rewrite rule:
RewriteRule ^a([0-9]*)/b([0-9]*).htm (points to) file.php?a=$1&b=$2
which matches the two variables, but if the href URL has extra vars, they don't get included, because they don't redirect correctly to file.php
So is it possible to have a sort of 'if' statement in the rewrite rule, or will I need a new rule entirely? My thought is that if I can say: if there's a question mark after the .htm, then append its trailing contents to the file.php string in the form of &vars. I get the impression that something like (?(?[a-z]*)) would work, but I'm not very good with regular expression (if only they were human readable! :p)
Does this make sense?
Cheers,
WW.
See the RewriteCond [httpd.apache.org] directive, and the [QSA] (query string append) flag of RuleRewriteRule [httpd.apache.org].
Jim