我正在尝试创建一个只能从批准的网站访问的页面,但我不知道如何处理它。我是否只需要提供一段生成随 secret 钥并将其附加到 URL 的 PHP 代码片段,并且该 key 仅对一次访问有效?
或者是否可以在其他域设置 cookie,然后在最终目的地读取?也许它会是一个 1px 的 iframe 在初始页面?
或者我只是想做一些永远行不通的事情?
最佳答案
在评论中,我们能够澄清...
I [zen] just need a method to secure a page without the need to have login credentials for each user, or any login for that matter. Another option I thought was to maybe do a POST send each time they click on a link, and my page would only allow them in if the POST contained a specific key. [...]
由于检测欺诈性访问不是问题,我建议您只需检查 http referer针对批准的站点(和/或页面)列表。它对已批准的站点是非侵入性的,并且提供的安全性不比您检查的固定后 token 差。
在 PHP 中,引荐来源网址位于 $_SERVER['HTTP_REFERER']
变量中(如果可用)。
关于php - 只允许从特定页面访问链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17310008/