Forum Moderators: phranque
/0/1/2/3/4/0123456789.gif
/S/O/M/E/W/SOMEWORD.gif
and thumbnails for most of my images:
/0/1/2/3/4/0123456789s.gif
I have my url rewrite working fine if the image exists:
RewriteRule ^(([A-Z0-9])([A-Z0-9])([A-Z0-9])([A-Z0-9])([A-Z0-9]).+)\.gif$ /$2/$3/$4/$5/$6/$1.gif [L]
Maybe a bit ugly, but it works. What I am trying to do is request the image:
/0123456789s.gif
if that doesnt exist, use the
/0123456789.gif
if that doesnt exist, default to
/not-found.gif
I thought I had this twice, but then when I would come back to it the next day it would not work (probably cache, eventually tears). I am comfortable playing with the regex, its just the logic that I am not getting. Would I use a chain/skip/next here?
Any help would be very much appreciated. I have been tempted to post about 2 dozen times, but really wanted to get it first! ;P
Thanks.
# If thumbnail exists
RewriteCond $1s.gif -f
RewriteRule ^(([A-Z0-9])([A-Z0-9])([A-Z0-9])([A-Z0-9])([A-Z0-9])[^.]+)\.gif$ /$2/$3/$4/$5/$6/$1s.gif [L]
# Else if file exists
RewriteCond $1.gif -f
RewriteRule ^(([A-Z0-9])([A-Z0-9])([A-Z0-9])([A-Z0-9])([A-Z0-9])[^.]+)\.gif$ /$2/$3/$4/$5/$6/$1.gif [L]
# Else use default
RewriteRule ^[A-Z0-9]{5}[^.]+\.gif$ /not-found.gif [L]
I get a request for the thumb image via: images.server.com/0123456789s.gif
The URL rewrites to images.server.com/0/1/2/3/4/0123456789s.gif
But if that rewritten thumbnail doesnt exist, rewrite again/instead to images.server.com/0/1/2/3/4/0123456789.gif
is there a way to do this? Am I missing something from your post?
thanks.