diff --git a/httprl.module b/httprl.module index 899bec5..1e98f34 100644 --- a/httprl.module +++ b/httprl.module @@ -204,7 +204,7 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) { // $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not // be modified by a visitor. if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) { - $base_path = "/$dir/"; + $root_path = "/$dir/"; } else { $root_path = '/'; @@ -217,8 +217,9 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) { $root_path = '/'; } // If ran from the command line SCRIPT_NAME contains the working directory. - elseif (!empty($_SERVER['PWD'])) { - $root_path = str_replace($_SERVER['PWD'] . '/', '', $root_path); + elseif (isset($_SERVER['argc']) || isset($_SERVER['argv'])) { + $cwd = isset($_SERVER['PWD']) ? $_SERVER['PWD'] : getcwd(); + $root_path = str_replace($cwd . '/', '', $root_path); } // Server auth.