我工作的一个数码产品制造商的网站。 产品图片是从数百个博客和放大器热链接;论坛。这是造成带宽的问题。
i am working on website of a Digital Gadgets Manufacturer. Product images are hotlinked from hundreds of blogs & forums. which is causing bandwidth issues.
我们希望与他们的低分辨率版本替换所有盗链图片,使用 的.htaccess
we want to replace all hotlinked images with their low resolution versions, using .htaccess
意味着如果热链接的图像路径是
means if the hotlinked image path is
www.example/products/gadget123/gadget123.png我们希望它重定向到
www.example/images/low-res/gadget123.png
热链接图像路径是不同的,意味着它们可以来自任何目录的子目录。
hotlinked image paths are different, means they may be from sub-directory of any directory.
例如
/images/products/abc/gadget_abc200.jpg /products/images/abc/gadgetabc5155_packing.png /downloads/brochures/abc2012/abc2012_user_guide.jpg etc...
但所有的低分辨率图像会在
but all low resolution images will be in
www.example/images/low-res/
目录,他们的名字将是相同的高分辨率版本。
directory, and their names will be same as their high resolution versions.
推荐答案尝试addopt这样的:
Try to addopt this:
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^(.*?)example\(/.*)?$ [NC] RewriteRule ^images/products/.+/(.+).png$ images/low-res/$1.png [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^(.*?)example\(/.*)?$ [NC] RewriteRule ^images/products/.+/(.+).png$ images/low-res/$1.png [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^(.*?)example\(/.*)?$ [NC] RewriteRule ^downloads/brochures/.+/(.+).jpg$ images/low-res/$1.jpg [L]此规则看,如果请求来自您的网站或直接从第三方。 并重写则请求
This rules looking for if the request comes from your site or directly from a third party. And rewrites then the request.
更多推荐
重定向热链接的图像与低分辨率版本
发布评论