[英]How can I restrict access to a PHP file so that it can only be reached via iframe in my server?
I have a content.php file on my server that I need to load in an iframe on another page mask.php .我的服务器上有一个content.php文件,我需要将它加载到另一个页面mask.php的 iframe 中。 This works just fine but I do not want content.php to be reachable at mydomain.com/content.php, only at mydomain.com/mask.php via iframe.
这工作得很好,但我不希望通过 iframe 在 mydomain.com/content.php 上访问content.php ,只能在 mydomain.com/mask.php 上访问。
Is there a way to restrict the access to content.php to only via iframe on same server?有没有办法限制对content.php的访问只能通过同一服务器上的 iframe? PHP or HTTP?
PHP 还是 HTTP?
I read about restricting the referrer of content.php , so that it has to be mask.php for it to load but it doesn't seam to work.我阅读了关于限制content.php的引用,因此它必须是mask.php才能加载,但它无法正常工作。 I can imagine that it should be doable with PHP.
我可以想象它应该可以用 PHP 实现。
mask.php掩码.php
<?php
if($_SERVER['REQUEST_URI']==='/mask.php' && $_SERVER['SCRIPT_NAME']==='/mask.php')
{
include("content.php");
}
?>
content.php内容.php
<?php
if($_SERVER['REQUEST_URI']==='/content.php' && $_SERVER['SCRIPT_NAME']==='/content.php')
{
die('No Access');
}
elseif($_SERVER['REQUEST_URI']==='/mask.php' && $_SERVER['SCRIPT_NAME']==='/mask.php')
{
echo 'hello';
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.