【发布时间】:2015-09-25 21:57:48
【问题描述】:
如果从其他站点访问,我如何使此文件重定向或阻止。
示例我想允许仅从我的站点 example.com 访问此脚本,如果任何其他站点尝试访问此 php 文件,是否可以阻止或重定向它
<?php
if (isset($_GET['id'])) {
if (isset($_SERVER['HTTP_RANGE']) && !empty($_SERVER['HTTP_RANGE'])) {
require_once './include/db.php';
require_once './include/video-stream.php';
$stm = $db->prepare("select * from video where code=?");
$stm->execute(array($_GET['id']));
if ($stm->rowCount() > 0) {
$row = $stm->fetch();
$stream = new VideoStream($row->path);
$stream->start();
} else {
header("message1");
echo "message2";
die();
}
}
【问题讨论】:
-
使用引荐来源网址并检查网址是否来自您的网站。 $_SERVER["HTTP_REFERER"];
-
if (isset($_SERVER['REFERER']) && !empty($_SERVER['HTTP_RANGE'])) {你觉得这个?
-
$_SERVER["HTTP_REFERER"]不可靠;阅读此stackoverflow.com/a/6023980 -
if($host=="www.example.com"){...}并添加了 twist ;-) 在那里,“像晚餐一样完成”。剩下的就交给你了。
标签: php hotlinking