This is odd, but for some reason the $_SERVER[\"SCRIPT_URI\"] will not return the domain name when I am in child/sub-pages but will only work on the main page.
$_SERVER[\"SCRIPT_URI\"]
Also, SCRIPT_URI does not exist, the right syntax is REQUEST_URI:
echo $_SERVER["REQUEST_URI"]; It returns the whole path without the host and domain.
echo $_SERVER["REQUEST_URI"];