【问题标题】:How to block access to one page and redirect to another如何阻止对一个页面的访问并重定向到另一个页面
【发布时间】:2021-02-19 11:27:06
【问题描述】:

好的。这就是我想做的事情。

假设我有三个页面:page1.htmlpage2.htmlpage3.html

我想限制对page2.html 的访问仅限于上一页为page1.html 的用户。
换句话说,如果访问者试图从page1.html 以外的任何网址访问page2.html,我想立即将他们重定向到page3.html

我将如何去做,我将把代码放在哪里?我尝试在网上查找信息,但始终找不到任何简单直接的答案。

你能帮帮我吗?

【问题讨论】:

  • 欢迎来到 SO。请每个问题只回答一个问题/主题。

标签: html redirect restriction


【解决方案1】:

您可以使用<meta http-equiv="refresh"/>

它会让你改变你当前的 URL。试着把它放在page2.html 上:

<!doctype html>
<html>
<head>
<meta http-equiv="refresh" content="0.1; url = page3.html" />
</head>
</html>

content 中,第一个数字表示重定向前要等待多少时间。你可以让它像五秒钟,然后添加一条消息说acces denied, redirecting in five seconds

【讨论】:

  • 太棒了。这解释了如何重定向,但让我说明我真正想做的事情。我想拒绝那些试图从 page1.html 以外的地方访问 page2.html 的人。换句话说,page1.html 应该是访问 page2.html 的唯一网关。如果它们不是来自 page1.html,我希望它跳到 page3.html。然后呢?
猜你喜欢
  • 2019-08-23
  • 1970-01-01
  • 2019-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-22
  • 1970-01-01
  • 2018-06-19
相关资源
最近更新 更多