diff --git a/route.php b/route.php index 31082f0..ab66c87 100644 --- a/route.php +++ b/route.php @@ -29,11 +29,19 @@ class route $this->module = $module; if ($this->baseURL !== "") return $this->baseURL; + + if (!isset ($_SERVER["SERVER_PORT"])) + $_SERVER["SERVER_PORT"] = 80; + $port = ":".$_SERVER["SERVER_PORT"]; + if (!isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 80) + $port = ""; + if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 443) + $port = ""; + if (isset ($_SERVER["SCRIPT_NAME"])) $this->baseURL = dirname ($_SERVER["SCRIPT_NAME"]); if (isset ($_SERVER["SERVER_NAME"])) - $this->baseURL = "//".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"] - .$this->baseURL; + $this->baseURL = "//".$_SERVER["SERVER_NAME"].$port.$this->baseURL; if (isset ($_SERVER["HTTPS"])) $this->baseURL = "https:".$this->baseURL; else @@ -75,8 +83,16 @@ class route $url = "https:"; else $url = "http:"; + if (!isset ($_SERVER["SERVER_PORT"])) + $_SERVER["SERVER_PORT"] = 80; + $port = ":".$_SERVER["SERVER_PORT"]; + if (!isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 80) + $port = ""; + if (isset ($_SERVER["HTTPS"]) && $_SERVER["SERVER_PORT"] === 443) + $port = ""; + if (isset ($_SERVER["SERVER_NAME"])) - $url .= "//".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"]; + $url .= "//".$_SERVER["SERVER_NAME"].$port; if (isset ($_SERVER["REQUEST_URI"])) $url .= $_SERVER["REQUEST_URI"]; return $url;