Rewriterule Image path

Hi experts,
For the purpose of Apache mod_write (ISAPI_Rewrite)

My pages contain some references to  images as 

But the images should be served from
and so on...

In other words we should ignore the characters between "images/" and "__imgname.[gif|png|jpg]"

Could someone please give me EXACT Rewriterule (and ReWritecond) for the above please.
A brief explanation will be appreciated.

Thanks a lot in advance :-)

Who is Participating?
HackneyCabConnect With a Mentor Commented:
How about:

RewriteCond %{REQUEST_URI} \.(gif|png|jpg)$
RewriteRule ^images/[^_]+_{2}(.*)$ /images/$1

This checks that the file requested ends with .gif or .png or .jpg and, if so, tells Apache to look in the images folder for the string that occurs after /images/blahblah__ (I've used a quantifier of 2 underscores, but change that number if the number of underscores is different, or a range).
I don't know how different ISAPI_Rewrite is from mod_rewrite, but this is how it would be done with mod_rewrite:

RewriteRule ^/?images/.*__(.*\.(gif|png|jpg))$ /images/$1 [L]
crazyguyindoreAuthor Commented:
Hi, sorry that does not seem to work as desired. ISAPI_Rewrite and mod_rewrite use same syntax.

I found another rewriterule which ignores the "/SomeFolder/" between (and serves images from instead)
RewriteRule ^/[^/]+/((images)/.*)$ /$1

But I still need to figure out how to ignore the extra string before after "/images/" and before "__" in should serve

Any help will be appreciated!

Thanks :-)

crazyguyindoreAuthor Commented:
Still no luck! any other ideas?

Thanks for your time.

should serve
crazyguyindoreAuthor Commented:
It worked actually.

And thanks for the explanation.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.