//detect true URI, inspired bu CodeIgniter 2 private static function detect_uri() { $uri = $_SERVER[‘REQUEST_URI‘]; if (strpos($uri, $_SERVER[‘SCRIPT_NAME‘] === 0)) { $uri = substr($uri, strlen($_SERVER[‘SCRIPT_NAME‘])); }elseif (strpos($uri, dirname($_SERVER[‘SCRIPT_NAME‘])) === 0) { $uri = substr($uri, strlen(dirname($_SERVER[‘SCRIPT_NAME‘]))); } if ($uri == ‘/‘ || empty($uri)) { return ‘/‘; } $uri = parse_url($uri, PHP_URL_PATH); return str_replace(array(‘//‘,‘../‘), ‘/‘, trim($uri,‘/‘)); }
时间: 2024-10-17 07:25:23