简体   繁体   English

如何知道用户已从哪个URL重定向到我们网站中的php页面

[英]how to know from which URL the user has been redirected to a page in our site in php

I have written a webservice client connected to a bank address. 我已经编写了一个连接到银行地址的Web服务客户端。 After the user is being sent to the bank's website and completes the from, then automatically is being redirected to the page named callback.php 将用户发送到银行的网站并完成从的操作后,然后自动将其重定向到名为callback.php的页面

Now, I want to know that from which address the user is being redirected to callback page?! 现在,我想知道用户是从哪个地址重定向到回调页面的? Is there a way to know it through PHP and of course if possible in codeigniter?! 有没有办法通过PHP知道它,当然,如果可能的话,也可以在codeigniter中知道它?

You should be able to access the referring location (if the user's browser has sent it, that is), with the following variable $_SERVER['HTTP_REFERER'] 您应该可以使用以下变量$_SERVER['HTTP_REFERER']访问引荐位置(如果用户的浏览器已将其发送)。

This should be accessible to you regardless of framework. 不论使用哪种框架,您都应该可以使用它。

There is no 100% way to solve this ... 没有100%的方法可以解决这个问题...

You can try to use the Referer which was sent .. .but this result can be manipulatet or edited by user/browser etc... 您可以尝试使用已发送的引荐来源..。但是此结果可以由用户/浏览器等操纵或编辑。

<?php 
    $_referer = $_SERVER["HTTP_REFERER"]; 
 ?>

Codeigniter has it own user agent class Codeigniter有自己的用户代理类

CI3 http://www.codeigniter.com/user_guide/libraries/user_agent.html CI3 http://www.codeigniter.com/user_guide/libraries/user_agent.html

As per what user guide said. 按照用户指南所说。

if ($this->agent->is_referral())
{
   echo $this->agent->referrer();
}

CI2 http://www.codeigniter.com/userguide2/libraries/user_agent.html CI2 http://www.codeigniter.com/userguide2/libraries/user_agent.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM