PHP中如何检查页面是直接加载还是从其他页面重定向?
假设我有两个页面 Page1.php 和 Page2.php。有时直接加载 Page1.php,有时从 Page2.php 重定向。我的问题是我可以检查 Page1.php 是直接加载还是从 Page2.php 重定向。(如果未使用查询字符串)
Suppose I am having two pages Page1.php and Page2.php. Sometimes Page1.php is directly loaded and sometimes it is being redirected from Page2.php. My question is that can I check whether Page1.php is directly loaded or it's being redirected from the Page2.php.(if query string is not used)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在Page2.php中设置会话变量并在Page1.php中对其进行控制
Page2.php
Page1.php
Set a session variable in Page2.php and control for it in Page1.php
Page2.php
Page1.php
您可以读取全局变量
$_SERVER['HTTP_REFERER']
的值。You can read the value of global variable
$_SERVER['HTTP_REFERER']
.$_SERVER['HTTP_REFERER']
查看手册以了解为什么它不可信:
https://www.php.net/manual/ro/reserved。变量.server.php
$_SERVER['HTTP_REFERER']
Though check out the manual to see why it cannot be trusted:
https://www.php.net/manual/ro/reserved.variables.server.php