View Single Post
Old 05-05-2008, 03:28 PM   #20 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

I tried the following which seemed to work ok on my system:

RewriteCond %{QUERY_STRING} ^[a-z0-9]{1,20}\.(?:jpe?g|gif|png|bmp)$ [NC]
RewriteRule ^image$ img.php?img=%0 [L]


One thing to note is that your PHP file shouldn't be named the same as what comes before the query string, ie image?test.jpg should not use image.php because it appears that Apache's content negotiation gets in the way and serves up the PHP page without going through the rewrite process. Simply rename the PHP page to something else as I have in my example above, img.php
Salathe is offline  
Reply With Quote