[英]Only allow to view a page that is redirected from example.com/login
I want a page that can be only accessible who is redirected from example.com/login
我想要一个只有从example.com/login
重定向的人才能访问的页面
As example, if I directly visit example.com/alice.php
it will redirect me to an error page.例如,如果我直接访问example.com/alice.php
它会将我重定向到错误页面。 example.com/alice.php
can be only accessible if a visitor was redirected from example.com/login
. example.com/alice.php
如果游客在重定向只能访问example.com/login
。
How can I do that with php?我怎样才能用 php 做到这一点?
perhaps you can use this as:也许您可以将其用作:
<?php
//your-url-which-you-do-not-what-direct access
$url != 'http://example.com/alice.php';
if ($_SERVER['HTTP_REFERER'] == $url) {
header('Location: http://example.com/error.php'); //redirect to some other page
exit();
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.