Abdulsattar Mohammed
Abdulsattar Mohammed

Reputation: 10712

How do you get the 'referer' header in PHP?

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

Upvotes: 12

Views: 32229

Answers (2)

TFM
TFM

Reputation: 544

$_SERVER['HTTP_REFERER']

The documentations are available here here.

Upvotes: 9

Stefan Gehrig
Stefan Gehrig

Reputation: 83622

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']

Upvotes: 28

Related Questions