dongzhong7299 2014-01-01 17:44
浏览 35
已采纳

什么可以是PHP脚本重定向网站的访问者基于多重尊重的推荐人[复制]

This question already has an answer here:

I am trying to redirect Visitors to a site based on their referrer url.

Visitors coming from "x" should be redirected to "x1" and Visitors coming from "y" should be redirected to "y1" and so on....

Here x and y are any website url(SOURCE) & x1 and y1 are also website url but these are DESTINATION..

i am trying to do the same with below written but its not working...

<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (preg_match("/site1.com/",$referrer)) {
header('Location: http://www.customercare.com/page-site1.html');
exit;
};
?>
</div>
  • 写回答

2条回答 默认 最新

  • doutong4088 2014-01-01 18:20
    关注

    Lets say you have a page x.php which is in the server and y.php which a particular user is comming from.

    Code for y.php

        <?php
    
         <a href="x.php">go to x</a>
        ?>
    

    Code for x.php

        <?php
        if(isset($_SERVER['HTTP_REFERER'])){//checking if user comming from other page or came here directly
    
           $referer = $_SERVER['HTTP_REFERER'];
        }
    
    //now the $referer holds path of y page
    //now you can use it to redirect
    
        if(//some condition){
          heder('Location:'.$referer);
    
        }
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号