Forum Moderators: phranque

Message Too Old, No Replies

Unlimited GET Queries in Rewrite Rule

Passing unknown number of variables

         

Shuriken1

5:43 pm on Apr 17, 2007 (gmt 0)

10+ Year Member



Evening all,

I stumbled across your forum last night and having had a reasonable look, couldn't find an answer so I thought I would ask the question directly.

I will warn you now that I have very little experience with mod_rewrite, but I can't find a way to do this - and without it, I have little point in using it.

So anyway, is it possible to pass an unknown number of variables through a mod_rewrite rule, for example:

www.example.com/show_product-a,b,c

to go to:

www.example.com/show_product.php?make=a&model=b&colour=c

Obviously this is possible using three back-references. The idea, however, is to be able to pass an unknown number of variables so I can have it in place whilst developing and have a single rule to meet any (within certain limits) use, on various pages and such-like.

Thanks in advance,

Shuriken1.

jd01

6:52 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Shuriken1,

Welcome to WebmasterWorld!

I'm not sure on the 'formal' mod_rewrite answer, but if it was me, personally, I would use something similar to Post 3 of this [webmasterworld.com...] recent thread, because I think it's a much cleaner and more efficient solution than you can achieve with only mod_rewrite.

What the rule states is to rewrite anything beginning with citystate/ to the corresponding php file. Then use php to 'grab' the requested URI and 'explode' out the variables using php rather than trying to 'match' each one individually.

Justin

<added>
You might use:
RewriteRule show_product[^.]+$ /show_product.php [L]

Which would match any url with show_product *not* containing a .(dot).
</added>

Sorry for the edits, a little tired today