I've search high and low for a solution to this. More than likely I'm just not using the right keywords.
I'm trying to rewrite some image urls to clean them up. Easy stuff.
I've managed to get urls from
Easy stuff using
RewriteRule ^h/(\d+)/w/(\d+)/a/([a-z]+)/thumb/(.+)$ /img/thumb.php?h=$1&w=$2&a=$3&src=$4 [L].
However I'm wanting to clean it up even further by defining this part in my .htaccess file:
h=400&w=550&a=c to remove
h/400/w/550/a/cfrom the image url so that the new thumb url is simply
I tried simply defining it in mod_rewrite like so but the image isn't changing to the defined sizes.
RewriteRule ^thumb/(.+)$ /img/thumb.php?h=400&w=550&a=c&src=$1 [L]
Is this not the right way to do it?
Since this is solved I want to elaborate on the usage for future viewers:
The end goal was to create various image sizes on the fly but with cleaner urls.
I am using my
.htaccess to contain the predefined sizes written in clean urls. There are five different sizes that I am using.
Here are the lines for creating these 5 sizes:
# CLEAN IMAGE URLS
# CREATE VARYING SIZED IMAGES WITH PREDEFINED SIZES
RewriteRule ^img/thumb/(.+)$ /img/thumb.php?h=400&w=550&a=c&f=2&src=/img/$1 [L]
RewriteRule ^img/small/(.+)$ /img/thumb.php?h=200&w=275&a=c&f=2&src=/img/$1 [L]
RewriteRule ^img/medium/(.+)$ /img/thumb.php?h=500&w=688&a=c&f=2&src=/img/$1 [L]
RewriteRule ^img/large/(.+)$ /img/thumb.php?h=750&w=1031&a=c&f=2&src=/img/$1 [L]
RewriteRule ^img/display/(.+)$ /img/thumb.php?h=600&w=600&a=c&f=2&src=/img/$1 [L]
This way for a
medium sizes image I simply wrote the url as
http://example.com/img/medium/folder/img.jpg and had an image with the dimensions of
500x688. This prevented me from having to have 5 different images of the same image uploaded to the server.