如何创建临时网址以防止在PHP中进行热链接? [英] How to create temporary urls to prevent hotlinking in php?

查看:139
本文介绍了如何创建临时网址以防止在PHP中进行热链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的上传网站,该网站将在输入验证码后为视频文件生成临时URL.我需要保护文件的真实位置,因此不能直接对其进行热链接.一个基于时间的url(在x分钟后过期)似乎是最好的选择,但是我不确定实际的实现方式.

Im looking to build a simple upload site, that will generate temporary URLS to video files after a captcha has been entered. I need to protect the true location of the files, so they cannot be hotlinked directly. A time based url, that expires after x minutes seems like the best option, but Im not sure on the actual implementation.

有什么提示吗?

推荐答案

使您的网址像这样:

http://myvid.com/video?id=1& timestamp = 12341561234& hash = 1203941h23jk479sdf87sdf

时间戳是unix时间戳,哈希是md5哈希,例如,附加到服务器上的机密字符串的时间戳.

Where timestamp is the unix timestamp and hash is an md5 hash, say, of the timestamp appended to a secret string on the server.

然后,当您播放该视频时,请检查时间戳记字段是否有效(通过使用哈希值),然后检查时间戳记的年龄.

Then, when you play that video, check if the timestamp field is valid (by using the hash), and then check to see how old the timestamp is.

这篇关于如何创建临时网址以防止在PHP中进行热链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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