© 2024 fjorge. All rights reserved.
PHP Get Real Current URL
I'm using this snippet to get the current url. It's fairly thorough, and needed it for a WordPress plugin I'm working on for startup weekend.
function get_real_current_url() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL .= "s";
}
$pageURL .= "://";
$pageURL .= $_SERVER["SERVER_NAME"];
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= ":".$_SERVER["SERVER_PORT"];
}
$pageURL .= $_SERVER["REQUEST_URI"];
return $pageURL;
}