仅当用户来自特定页面或链接时才使网页可见 [英] Making a web page visible only when user comes from a specific page or link

查看:60
本文介绍了仅当用户来自特定页面或链接时才使网页可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何使网页仅对来自特定页面或链接的用户可见?如果稍后直接从​​浏览器或从任何其他来源而不是指定的页面或链接访问该页面的链接,给出错误,或重定向到其他页面.

How would you make a web page visible only for the users that come from a specific page or link? If the page's link is accessed later directly from the browser, or from any other source instead of the specified page or link, give an error, or redirect to other page.

如果是,请告诉我你会怎么做,以及你的建议是什么.

If yes, please let me know how would you do it, and what your recomendations are.

推荐答案

我认为对你有用的是 $_SERVER['HTTP_REFERER'] - 查看详情

I think something what can be useful for You is $_SERVER['HTTP_REFERER'] - see details

使用此变量,您可以简单地检查用户来自何处并决定在服务器端显示或不显示您网站的其他页面

With this var You can simply check from where user has came and decide on server side to show or not another page from your website

在伪代码中

<?php

if ('a-referer-identificator' === $_SERVER['HTTP_REFERER']) {

echo 'show your website';

} else {
// Redirect for access denied or sth like that
header('Location: http://www.example.com/');
}

?>

这篇关于仅当用户来自特定页面或链接时才使网页可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆