Krist van Besien wrote:
On 5/14/07, Arthur Kerpician <arthur@xxxxxxxxxxx> wrote:Hi, Im having trouble with defining some rules. This is the layout: I want to send some GET vars in the URL like this: http://localhost/a-1,b-2,c-3,d-4/ Based on this format, the rewriting engine should forward the request like this: http://localhost/index.php?a=1&b=2&c=3&d=4 I know I can write a rule like this: RewriteRule /a-([0-9]+),b-([0-9]+),c-([0-9]+),d-([0-9]+) /index.php?a=$1&b=$2&c=$3&d=$1 The problem is that one or more of these vars can be missing (some of them are filters, order by data info) or can be send in a different position than the one defined by the rule, something like this: http://localhost/d-1,a-2/ (should rewrite to http://localhost/index.php?d=1&a=2) or http://localhost/c-1/ (should rewrite to http://localhost/index.php?c=1) The hard way, as I see it, is to take into account all combinations / possibilities and write a rule for each and every case. Im not a even close to be a mod_rewrite fair user but I know there should be an easier (optimised) way of doing this.I asume that the order in which index.php gets its parameters is not that imporant. You could then do something like this: RewriteRule (.*),?([a-z])-([0-9]+)$ $1?$2=$3 [N,QSA] This will strip one letter-number pair of your URL, and add it to the query string. The "N" flag than makes rewrite rule processing start over again, until the rule no longer matches. Krist
Thanks Krist, A little bit of tweaking and your rule worked for me! --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx