$ _SERVER ['HTTP_REFERER']总是空的 - PHP
<?php
$camefrom =$_SERVER['HTTP_REFERER'];
if ((substr($camefrom,0,26) == "http://www.fromperson.com")
header( 'Location: http://toperson.com' ) ;
?>

I need to redirect to www.to.com if the request was made from www.from.com. This code resides in www.thridperson.com/index.php

$camefrom is always empty.

I have read that $_SERVER['HTTP_REFERER'] is not reliable. Is there any other way to perform this redirection?

Note: I have lost the access to old domain i.e fromperson.com. So, I cannot change this redirection logic it has to be done this way and it has to done only in thirdperson.com/index/php

dqdmvg7332
dqdmvg7332 我在问题上遇到了同样的问题。你能详细介绍一下你提到的GET参数吗?你能给出一个具体的例子,以便我可以效仿吗?-PamApple
大约 8 年之前 回复
douping1581
douping1581 HanÄiÄ感谢您的帮助:)
接近 10 年之前 回复
duanke6057
duanke6057 没有我知道的。
接近 10 年之前 回复
dongzhu6900
dongzhu6900 HanÄiOMG!:(任何使用Javascript的工作?
接近 10 年之前 回复
dongshan1811
dongshan1811 根据你最新的编辑,我担心你运气不好。抱歉。
接近 10 年之前 回复

2个回答



根据我的要求无法做到</ p>
</ div>

展开原文

原文

No way to do according to my requirement



$ _ SERVER ['HTTP_REFERER'] </ code>确实不可靠。 客户端(浏览器)不需要将其包含在请求中。 如果您需要一个始终有效的防弹解决方案,您必须在`fromperson.com'上对您的应用程序进行moddiffy以在链接到您的网页时包含一些GET参数,然后您可以检查该GET参数是否存在然后执行 重定向。</ p>
</ div>

展开原文

原文

$_SERVER['HTTP_REFERER'] is indeed unreliable. A client (browser) is not required to include it in the request. If you need a bullet-proof solution that will always work you will have to moddiffy your application on `fromperson.com' to include some GET parameter when linking to your web page, and then you can check if that GET parameter exists and then do the redirect.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问