How to get the full request URL of the page being processed in PHP?
If you are sure the request is a http or https one, and the PHP script is executed according to (e.g. by a load balancer or apache reverse proxy) the REQUEST_URI
/HTTP_HOST
which are set by the client, the PHP script can get the actual URL by
$url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
If it is necessary, escape the $url
such as:
$url = htmlspecialchars($url, ENT_QUOTES, 'UTF-8');