flashflavour
flashflavour

Reputation: 11

phpthumb & htaccess

if i have an image (/uploads/image.jpg), and i have a script (/phpthumb/phpThumb.php) that resizes the image and shows it (not saving!).

I print the image like this:

<img src="/phpthumb/phpThumb.php?src=../uploads/image.jpg&w=100&h=100" alt="" />

Is it possible to change it to this (with a directory 'thumbs' that doesn't exist):

<img src="/thumbs/image.jpg?w=100&h=100" alt="" />

And rewrite the url with htaccess (i tried the code below, but no luck):

RewriteRule ^thumbs/(.*).(jpg|gif|png)\?(.*)$ /phpthumb/phpThumb.php?src=../uploads/$1.$2&$3 [L]

Thanks in advance

Upvotes: 1

Views: 524

Answers (1)

Alex
Alex

Reputation: 436

Query string cannot be rewriten, so I suggest you a different approach

The request url:

/thumbs/image-100x100.jpg

Htaccess:

Rewrite

Engine On
RewriteRule ^thumbs/([a-zA-Z0-9_]+)-([0-9]+)x([0-9]+).(jpg|gif|png)(.*)$ phpthumb.php?src=../uploads/$1.$4&w=$2&h=$3 [L]

You will get in php file:

Array
(
    [src] => ../uploads/image.jpg
    [w] => 100
    [h] => 100
)

Upvotes: 0

Related Questions