重定向热链接的图像与低分辨率版本 [英] Redirecting Hotlinked images with Low Resolution versions

查看:147
本文介绍了重定向热链接的图像与低分辨率版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个数码产品制造商的网站。 产品图片是从数百个博客和放大器热链接;论坛。这是造成带宽的问题。

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

http://www.example.com/products/gadget123/gadget123.png

我们希望它重定向到

http://www.example.com/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

http://www.example.com/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\.com(/.*)?$ [NC]
RewriteRule   ^images/products/.+/(.+).png$ images/low-res/$1.png  [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(.*?)example\.com(/.*)?$ [NC]
RewriteRule   ^images/products/.+/(.+).png$ images/low-res/$1.png  [L]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^(.*?)example\.com(/.*)?$ [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.

这篇关于重定向热链接的图像与低分辨率版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆