this is a pain in the ass-problem! Whicever genius solves this riddle will receive paypal donation to eat diner for two. Now lets get started. Given: most proxies, do not cache resources with a "?" in their URL even if a Cache-control: public header is present in the response. To enable proxy caching for these resources, i have to remove query strings from references to static resources, and instead encode the parameters into the file names themselves.*
PREVIOUSLY HAD
<img src="/imgcpu?src=folder1/photo_citty.jpg&w=3500&h=10&c=p&q=90" />
<img src="/imgcpu?src=folder2/photo_doggy.jpg&w=100&h=200&c=p" />
<img src="/imgcpu?src=folder3/photo_birds.jpg&w=200&h=500&f=bw" />
<img src="/imgcpu?src=folder3/photo_frogs.jpg&h=200" />
NOW WORKING
<img src"/IMG-folder/photo_w100_h100_cf_q60.jpg"/>
- The images will reside in 1 folder deep on the root (never deeper)
- the img.php?src= or img?src= will be consistently named this forever
- after the ....jpg &w,&h,&q,&m, &f and &c are the only letters that call for variables (e.g.: &w=200&h&=50&c=p&f=bw&q=90) but all should be optional
AT THE COST OF THIS UN-ELEGANT CODE
# Rewrite imgcpu?src= thumbnail maker to nice static urls
RewriteCond %{REQUEST_URI} ^IMG.*$
RewriteRule ^IMG-(.+)_w(.+)_h(.+)_c(.+)_q(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&c=$4&q=$5 [L]
RewriteRule ^IMG-(.+)_w(.+)_h(.+)_c(.+)_f(.+)_q(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&c=$4&f=$5&q=$6 [L]
RewriteRule ^IMG-(.+)_w(.+)_h(.+)_c(.+)_f(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&c=$4&f=$5 [L]
RewriteRule ^IMG-(.+)_w(.+)_h(.+)_c(.+)_q(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&c=$4&q=$5 [L]
RewriteRule ^IMG-(.+)_w(.+)_h(.+)_c(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&c=$4 [L]
RewriteRule ^IMG-(.+)_w(.+)_h(.+)_f(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&f=$4 [L]
RewriteRule ^IMG-(.+)_w(.+)_h(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3 [L]
RewriteRule ^IMG-(.+)_w(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2 [L]
RewriteRule ^IMG-(.+)_h(.+).jpg$ imgcpu\?src=$1\.jpg&h=$3 [L]
However, endless other possibilities are still uncovered: e.g. doesnt cover the cases where first the height is given the width etc No this shall not work! How can I redirect OPTIONALLY ALL parameter? &w= or &h= with something like &[a-z]=(.*) sothat _h or _w or _m are all universal and optional and when given intervepted by the rewritten, proxy friendly urls?
So the assignment Now is:
Rewrite any or all of the queries that follow [photo123.jpg]&[a-z]=(.*)&[a-z]=(.*)etcettera
into photo123_X-x_Y-y(optionally more queries).jpg