重定向热链接的图像与低分辨率版本

编程入门 行业动态 更新时间:2024-10-27 10:33:46
本文介绍了重定向热链接的图像与低分辨率版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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.

更多推荐

重定向热链接的图像与低分辨率版本

本文发布于:2023-11-01 11:20:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549200.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   图像   低分   版本   链接

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!