What are the limitations of using $REQUEST_URI to retrieve the page URL in PHP?

$REQUEST_URI may not always return the exact page URL due to server configurations or URL rewriting. To retrieve the actual page URL, it's recommended to use a combination of $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'].

$pageURL = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
    $pageURL .= "s";
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
    $pageURL .= $_SERVER["HTTP_HOST"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
} else {
    $pageURL .= $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
}

echo $pageURL;