Mod_rewrite with multiple variables

Posted by Andrei on Stack Overflow See other posts from Stack Overflow or by Andrei
Published on 2010-05-10T18:20:00Z Indexed on 2010/05/10 18:24 UTC
Read the original article Hit count: 236

Filed under:
|
|
|
|

Hello,

I'm using a PHP script that dynamically generates transparent PNGs for use as CSS backgrounds from a query string that takes RGBa and HSLa values. The original script can be found here, I've only added HSLa support.

Because background URLs with PHP query strings aren't very pretty, and because it seems to break the IE 6 transparent PNG hack, I thought of using mod_rewrite to allow the script to be called when a .png with this syntax is called :

/assets/colors/h[0-360 value]_s[0-100 value]_l[0-100 value]_a[0-100 value].png

which would be rewritten to :

/assets/colors.php?h=[0-360 value]&s=[0-100 value]&l=[0-100 value]&a=[0-100 value]

Here's the issues I'm encountering :

  • passing multiple variables with mod_rewrite
  • using an underscore as a delimiter

I know this could be done by passing a single variable and then exploding it in the PHP script, however I would prefer it to be done by Apache.

Thanks in advance and if anyone wants my HSLa enabled version of the script just ask. Anyway I recommend you check it out on it's author's website.

© Stack Overflow or respective owner

Related posts about mod-rewrite

Related posts about php