diff --git a/route.php b/route.php index a6a8062..d0394ae 100644 --- a/route.php +++ b/route.php @@ -127,11 +127,29 @@ class route { // Calculate the root in relative $request = $this->requestURL (); + if (substr ($_SERVER["REQUEST_URI"], -1 * strlen ($request)) === $request) + { + $this->baseURL = substr ($_SERVER["REQUEST_URI"], 0, + strlen ($_SERVER["REQUEST_URI"]) - strlen ($request)); + } + elseif ($_SERVER["REQUEST_URI"] !== "") + { + $this->baseURL = $_SERVER["REQUEST_URI"]; + } + else + { + $this->baseURL = "/"; + } + /* + // This part was to get really relative to current directory (with ../) + // But it is not really well supported by the bad coded crawlers. So, the + // URL is now relative to base of URL $this->baseURL = str_repeat ("../", substr_count ($request, "/")). $this->baseURL; if ($this->baseURL === "") $this->baseURL = "./"; + */ } $this->baseURLmodule = $this->baseURL; // Only != NOT !== (cause : $this->module can be converted in string "0")