public function pathToString($path, $rewrite = false)
    {
        if (is_string($path)) {
            return $path;
        }
        $str = $this->basePath;
        if ($str == '/') {
            $str = '';
        }
        if (! ($this->rewrite or $rewrite)) {
            $str .= '/' . $this->scriptName;
        }
        $str .= '/' . implode('/', array_map('urlencode', $path));
        $str = rtrim($str, '/');
        if ($str == '') {
            return '/';
        }
        return $str;
    }