I have a website with a lot of images. Say these images are stored in the "/ data / images" folder. I also have a folder with watermarks: "/ data / wimages". The source and watermark names are the same, but not all images have a watermarked copy. So, I want to redirect the source image (without changing its URL in the browser or in the HTML source), if the watermark represents and passes through the source image, if not. I am trying to solve this problem using Apache mod_rewrite:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} ^.*/data/images/.*\.(gif|jp?g|png)$ [NC]
RewriteRule ^data/images/(.*\.(gif|png|jp?g))$ /data/wimages/$1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^data/wimages/(.*\.(gif|png|jp?g))$ /data/images/$1 [NC,L]
then I restore the previously changed url and get an infinite loop!
Any ideas?
PS Sorry for my English.
anton source
share