是否可以阻止 iframe 的内容仅从浏览器调用?
例如;
domain.com/index.php
中有 iframe.php
。
index.php
iframe.php 也有 session 。但是当 session 开始时,用户可以调用 iframe.php
作为
domain.com/iframe.php
最佳答案
如果javascript是一个选项,您可以检测iframe
是否直接在浏览器中打开:
<script type="text/javascript">
if (top.location == self.location) {
top.location = "http://homepage.com";
}
</script>
另一个选项是使用 $_SERVER['HTTP_REFERER']
,如前所述here .
关于php - 如何阻止浏览器调用 iframe 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21203432/