diff --git a/route.php b/route.php index fda3e2b..b481be1 100644 --- a/route.php +++ b/route.php @@ -45,9 +45,9 @@ class route if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === "443") $port = ""; - $this->baseURL = ""; if ($absolute === true) { + $this->baseURL = ""; if (isset ($_SERVER["SCRIPT_NAME"])) $this->baseURL = dirname ($_SERVER["SCRIPT_NAME"]); if (isset ($_SERVER["SERVER_NAME"])) @@ -66,7 +66,10 @@ class route $root = dirname ($_SERVER["SCRIPT_NAME"]); $requestdir = substr ($request, 1+strlen ($root)); $this->baseURL = str_repeat ("../", - substr_count ($requestdir, "/")). $this->baseURL; + substr_count ($requestdir, "/")). + $this->baseURL; + if ($this->baseURL === "") + $this->baseURL = "./"; } $this->baseURLmodule = $this->baseURL; // Only != NOT !== (cause : $this->module can be converted in string "0") @@ -134,12 +137,14 @@ class route if (php_sapi_name () === "cli") exit; $destURL = trim ($destURL); - $baseURL = $this->baseURL (); + $baseURL = $this->baseURL ($module); +echo "baseURL=$baseURL,SCript=".$_SERVER["SCRIPT_NAME"]; if ($module !== "") $baseURL .= $module."/"; $requestURL = $this->requestURL (); if (substr ($requestURL, -1) !== "/") $requestURL .= "/"; +echo "destURL=$destURL,baseURL=$baseURL,module=$module"; if ($destURL[0] === "/") { // Absolute : return to project base