重定向和引用 [英] Redirects and Referers

查看:51
本文介绍了重定向和引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此的实际实现要复杂得多,包括身份验证和一堆其他东西,但以最简单的形式,这就是我遇到的问题.使用标头重定向不会显示为引用者.

My actual implementation of this is much more complicated, with authentication and a bunch of other stuff, but at the simplest form, here's the problem I'm having. Redirecting with header doesn't reveal itself as a referer.

所以,假设我有三个页面:start.php、middle.php 和 end.php

So, let's say I have three pages: start.php, middle.php and end.php

start.php

<html><body>
<a href="middle.php">middle</a>
</body></html>

中.php

<?php
header('Location: end.php');
?>

end.php

<?php
    echo 'The referer is: ' . $_SERVER['HTTP_REFERER'];
?>

当您点击链接时,您最终会到达 end.php,但引用者不是 middle.php.有没有其他重定向方法可以用来纠正这个问题,或者我可以做些什么?

When you follow the link, you end up at end.php, but the referer is not middle.php. Is there any other redirection method I can use to correct this, or anything else I can do?

干杯

编辑在这种情况下,目标页面是第三方供应商.他们必须验证的唯一方法是引用 URL.我对此无能为力.我只需要我的页面进行重定向以发送正确的 URL.除了挑出不信任 http_referer 的理由之外,还有其他方法可以替代这种重定向方法吗?

EDIT In this case, the destination page is a third party vendor. The only method they have to validate is from refering URL. I have no control over that. I just need my page that does the redirect to send the proper URL. Are there any alternatives to this redirection method, rather than picking apart the reasons not to trust http_referer?

推荐答案

我采用了旧的元刷新重定向方法.这可以为需要它的供应商保留引用 URL.任何不需要它的供应商仍然使用标头功能,以提高速度和易用性.

I went with the old meta refresh method of redirection. This keeps the referring URL in tact for the vendors that require it. Any vendor that doesn't require it still uses the header function, for speed and ease of use.

这篇关于重定向和引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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