开发者

$_SERVER['HTTP_REFERER'] is always empty - 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 f开发者_开发知识库romperson.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


$_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.


No way to do according to my requirement

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜