php - 不会根据iframe

时间:2017-12-20 21:11:24

标签: php iframe

我有一个带有iframe的页面,其中包含以下代码。基本上我希望它像一个门户网站。根据他们访问的页面,他们会看到不同的东西。当我尝试使用echo获取引用者时,它设法获取父URL但不会正确重定向。相反,它会转到默认值。我想知道这是否是不可能的事情?

$referrer = $_SERVER['HTTP_REFERER'];

switch($referrer) {
   case "https://domain1.org":
      header("Location: https://example.org/one");
      break;
   case "http://domain2.org");
      header("Location: https://example.org/two");
      break;
   case "https://domain3.org":
      header("Location: https://example.org/three");
      break;
   default:
      header("Location: https://example.org");
}

编辑1:如果我将其更改为iframe网址而不是父网址,则只会重定向到案例标头。否则它将重定向到默认标题。

编辑2:我在这里设置了一个测试环境。问题仍然存在。

1 个答案:

答案 0 :(得分:0)

向iframe URL添加变量,以便它检测给定变量而不是父URL。不是我想到的,但在我的情况下作为替代方案效果很好。

- Customer1: nextCustomer = Customer2
- Customer2: nextCustomer = Customer2, prevStandstill = Customer1
- Customer3: prevStandstill = Customer2