WOW, thanks Aleksandar. that works for my.
I hope you can help me with another rewrite.
from:
http://www.my-domain.de/attachments/hundebilder-hundefotos-fotowettbewerbe/67591d1394397097-hund-monats-april-2014-dsc06022.jpg
to:
http://www.my-domain.de/attachments/dsc06022-jpg.67591/
OR
from
http://www.my-domain.de/attachments/alte-fotowettbewerbe-hunde/61955d1389003298-hund-jahre-2013-hund-mai.jpg
to
http://www.my-domain.de/attachments/hund-mai-jpg.61955/
My attempts have all failed.