PHP, PNG's and Query Strings

Using mod_rewrite to handle various content issues

PHP, PNG's and Query Strings

Postby SimFord » Tue Nov 28, 2006 10:47 am

I have a PHP page which chooses a PNG picture at random, and adds a string of text to it.
I've sucessfully done the mod_rewrite thing so a .PNG refers to the PHP page, and it works brilliantly.

Problem now is, I'm trying to improve this so I can pass a value into the PHP in the form of a query string and get it to determine the output depending on this value. I've managed to get the PHP to do this directly, but what I really want is to pass a query string to the 'fake' PNG reference and have it work that way too.

What I basically want to do is:

sig1.png ---> sig.php?sig=1
sig2.png ---> sig.php?sig=2
sig3.png ---> sig.php?sig=3

or a similar varient/variation of this, maybe sig.png,1 or sig,1.png

Thanks in advance,
Posts: 1
Joined: Tue Nov 28, 2006 10:17 am

Postby richardk » Tue Nov 28, 2006 3:42 pm

In a .htaccess file:
Code: Select all
Options +FollowSymLinks

RewriteEngine On
RewriteRule ^sig([0-9]+)\.png$ sig.php?sig=$1 [L]
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Return to Content

Who is online

Users browsing this forum: No registered users and 2 guests