How do you get the 'referer' header in PHP

2020-02-06 02:01发布

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

2条回答
霸刀☆藐视天下
2楼-- · 2020-02-06 02:21

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']
查看更多
三岁会撩人
3楼-- · 2020-02-06 02:28
$_SERVER['HTTP_REFERER']

The documentations are available here here.

查看更多
登录 后发表回答