请求源

2022-01-05 00:00:00 request php httprequest

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?

解决方案

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.

相关文章