【问题标题】:How to redirect from a link to another?如何从一个链接重定向到另一个?
【发布时间】:2020-04-23 02:34:41
【问题描述】:

如果我在此链接上 website.com/index.php?id=19 我希望如果您尝试删除 ?id=.. 这样链接将只是 website.com/index.php 用户将被重定向到 website.com/index.php?id=.. 我该怎么做?

【问题讨论】:

  • 在这种情况下,我使用 url 令牌,这样用户就不会使用 url 或查询字符串。 url?token={token value}您可以将密钥值存储在加密的令牌中以确定您需要执行的操作。
  • 谢谢大佬,看看它是如何工作的!

标签: php redirect hyperlink


【解决方案1】:

使用header 和$_GET - 例如:

if (!isset($_GET['id']) || empty($_GET['id'])) {
   header('Location: /index.php?id=155');
   exit();
}

155 是你想要的任何东西。

【讨论】:

    【解决方案2】:

    你可以这样试试

    if(!isset($_GET['id']))
    {
       header('location:index.php?id=here is your id value');
       exit;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      • 2019-02-16
      • 1970-01-01
      相关资源
      最近更新 更多