Jump to content

re-write keeping $_GET variables from url


Dragen

Recommended Posts

Hi,

I'm using htaccess to re-direct an image link to a php file, with the get variables set within the url. something like this:

http://localhost/counter/3/W300/H200/img.png

I've got my htaccss working fine for that. It takes the bits between 'counter' and 'img.png' and turns them into gets.

Now what I'm trying to do is also to use get variables in the image url, like this:

http://localhost/counter/3/W300/H200/img.png?color=32&width=1280&height=800

and get htaccess to keep the variables when it rewrites the url. Unfortunately it removes them and I can't seem to get them with htaccess. Here's my htacces I'm using:

RewriteRule ^counter/(([a-zA-Z0-9.]+/)+)img.png$ counter.php?p=$1$3 [L]

This one gets the bits between counter and img.png.

 

This is what I'm using to try and get the GET vars:

RewriteRule ^counter/(([a-zA-Z0-9.]+/)+)img.png([a-zA-z0-9./]+)?$ counter.php?p=$1$3 [L]

But it's not working.

Any suggestions?

 

note: before anyone says anything, I've tried using $2, but because of how my rewrite is written, $2 comes out as the last item in the 'counter' -> 'img.png' section..

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.