如何在 PHP 中获取“referer"标头?

2022-01-17 00:00:00 http-headers php

我想要发出请求的页面的 url.我怎样才能在 PHP 中做到这一点?

I want the the url of the page from which a request has been made. How can I do that in PHP?

推荐答案

refer(r)er 可以在 $_SERVER 全局变量中找到.请注意,发送refer(r)er 是完全可选的,用户代理可以简单地决定不发送refer(r)ing url.

The refer(r)er can be found in the $_SERVER global variable. Please note that sending the refer(r)er is completely optional and a user-agent can simply decide to not send the refer(r)ing url.

$_SERVER['HTTP_REFERER']

相关文章