Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

source of REQUEST

How do I get the url from which the request was submitted. I tried $_SERVER['REQUEST_URI']; but this gives me the destination url not the source url. Is it possible to get the origin?

like image 843
samuel Avatar asked Nov 07 '10 13:11

samuel


2 Answers

You are looking for $_SERVER['HTTP_REFERER'];

Note:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

like image 114
Sarfraz Avatar answered Nov 07 '22 12:11

Sarfraz


$_SERVER['HTTP_REFERER'] will work, if it is provided by the calling browser. Note that it is provided by the client so it may be empty or faked, so don't trust it security-wise.

like image 28
Emil Vikström Avatar answered Nov 07 '22 12:11

Emil Vikström