This rule fails because it has / . Thus, the redirected URL ( _images/12940.png ) falls into the rule again, and mod_rewrite tries to redirect it ( _images/_images/12940.png ).
So you should check if the allready path starts with _images :
RewriteRule ^(?!_images)([A-Za-z0-9\_\-\/]+).([A-Za-z]+)$ "_images/$1.$2"
You can also improve your rule as follows:
RewriteRule ^(?!_images)([a-z0-9_\-/]+\.[az]+)$ _images/$1 [NC]
There is no need to avoid _ and / , but you must avoid . because it matches any character otherwise. NC makes the rule case insensitive, so you do not need additional AZ .
source share