【问题标题】:Two stage redirect [closed]两阶段重定向[关闭]
【发布时间】:2014-07-21 01:11:02
【问题描述】:

我正在为我的网站 www.listprice.us 寻找一个两阶段重定向,它会在将用户重定向到新网站之前发出异地许可通知。我有一百万个异地重定向,需要他们转到一个带有最终目标链接的新页面并在那里暂停,直到用户通过同意按钮同意离开我的网站。我对 html、java 和 php 半流利,除了显然越简单,解释得越好越好。

【问题讨论】:

  • 像你一样,我们也喜欢更简单和更好解释的问题:)

标签: php url redirect


【解决方案1】:

创建一个页面,例如getpermission.php

通过 GET 将目标 URL 带到该页面。

使用从GETPOST 中提取的链接创建一个链接,例如“是的,我同意”。

希望这会有所帮助:)

编辑:

GET: www.mysite.com/getpermission.php?url=www.thesite.com

<a href="<?php echo $_GET['url']; ?>"> YES I Agree </a>

每个问题添加的来源:

$askconsent = false; //set to true to ask for consent

if ($_GET) { //url has been presented with a GET.
    $url = isset($_GET['url']) ? $_GET['url'] : 'www.domain.com'; //lets make sure url is set. If null set to home.
    //Make sure this has been sanitized before hitting your database if its in one.

    if ($askconsent) { //do we require consent yet?
        echo '<a href="' . $url . '"> Would you like to continue?</a>'; //Present the user with the option to move on.
    } else { // no consent needed.
        header('Location: ' . $url); //go to url from GET
    }
} else { // if we are not presented with a get, we must assume the user got here without wanting or needing to.
    header('Location: www.domain.com'); //Send them home!
} 

【讨论】:

  • 请注意:如果用户能够将这些链接输入到数据库中,我将对其进行清理和 PDO。
  • 这个我明白了。简单就是这么好。下一步.. 我需要一个 getpermission.php 的替换页面,它将暂时替换这个“我同意”表达式,并且不会中断直接到达最终目的地。允许我在以后根据需要仅通过更改 getpermission.php 而不是数万个网页来激活此检查。
  • 我一定会梦寐以求理解的复杂性,只有我的流利程度才能在其中找到: 回答我问题的后半部分。
  • 我发现找出你没有学过的东西,然后强迫自己去学习它们是最好的方法。编写代码,这很糟糕,研究,使代码更好,测试,冲洗重复。我从这个方法中学到了我所知道的一切:P 祝你好运。
猜你喜欢
  • 2012-08-25
  • 1970-01-01
  • 2012-04-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-03
  • 1970-01-01
  • 2014-12-24
相关资源
最近更新 更多