Skip to content

Instantly share code, notes, and snippets.

@gourneau
Created November 29, 2010 06:34
Show Gist options
  • Save gourneau/719659 to your computer and use it in GitHub Desktop.
Save gourneau/719659 to your computer and use it in GitHub Desktop.
Find the full URL that a PHP script is running at , minus the name of the file
//Find the full url to the site we are at
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
$address = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$currentFile = $parts[count($parts) - 1];
$site_path = str_replace($currentFile,'',$address);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment