用于链接到图像的简单间接方法
我有一个网站,其中托管图像可以直接共享和链接。我在某处读到这是一个坏主意。我如何应用简单的间接方法,同时保留现有链接一段时间,直到它们从 Facebook 上消失?
I have a web site which hosts images are shared and linked directly. I've read somewhere that this is a bad idea. How could I apply simple indirection approach while perhaps keeping existing links up for a while until they disappear off Facebook?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是旧答案。
创建无法直接链接到的链接的示例:
使用如下:
在生成的链接中放入两位信息:图像 ID 和链接到期的时间(因此您无法直接链接)。此外,您还添加了一个哈希值,这样就没有人可以“弄乱”变量,只有您知道如何生成哈希值(取决于
$secretpassword
)。这些链接会在 5 分钟后过期,或者您设置的
$expire
后过期。一个问题是这些链接看起来不太漂亮。我知道让它们看起来更漂亮的方法,但这超出了这个问题的范围。
旧答案
我假设您的意思是您共享其他域(例如 Facebook)上的图像。
您描述的问题是您通过使用其他域的图像(和带宽)来“窃取”其他域。我不知道 Facebook 关于直接链接的政策,但对于较小的网站来说,这是一个真正的负担。添加间接并不能解决这个问题。
解决此问题的唯一方法是将图像上传到图像服务器,可以是免费的,也可以是您自己控制的服务器。您可以让您的用户执行此操作,或者您也可以为他们执行此操作。
如果您不控制图像服务器,则很难实现自动化,但拥有图像服务器可能会非常昂贵(带宽很昂贵)。让用户这样做会给他们带来负担,并且可能会降低您的网站的吸引力,因为他们需要执行额外的步骤。
我认为这些是你可以选择的。
Old answer below.
Example for making links that you can't direct link to:
Use like:
You put two bits of information in the links you generate: the image id and the time when the link should expire (so you can't direct link). Additionally you add a hash so that no one can 'mess' with the variables, only you know how to generate the hash (depends on
$secretpassword
).These links expire after 5 minutes, or whatever you set
$expire
to.One issue is that these links don't look very pretty. I know ways to make them look prettier but that's beyond the scope of this question.
Old answer
I assume you mean that you share images that are on other domains (like Facebook).
The problem you describe is that you're 'leeching' off the other domains by using their images (and bandwidth). I don't know Facebook's policy about direct links but for lesser sites it's a real burden. Adding indirection isn't going to solve this problem.
The only way to solve it is to upload the images to an image server, either a free one or one that you control yourself. You could have your users do this, or you can do it for them.
Automating it is hard if you don't control the image server, but having an image server can be very costly (bandwidth is expensive). Having users do it places the burden on them and might make your site less attractive because they need to perform an extra step.
I think these are the options you have.