$request = Request::instance();
    // 获取当前域名
    echo ‘domain: ‘ . $request->domain() . ‘
    ‘;
    // 获取当前入口文件
    echo ‘file: ‘ . $request->baseFile() . ‘
    ‘;
    // 获取当前URL地址 不含域名
    echo ‘url: ‘ . $request->url() . ‘
    ‘;
    // 获取包含域名的完整URL地址
    echo ‘url with domain: ‘ . $request->url(true) . ‘
    ‘;
    // 获取当前URL地址 不含QUERY_STRING
    echo ‘url without query: ‘ . $request->baseUrl() . ‘
    ‘;
    // 获取URL访问的ROOT地址
    echo ‘root:’ . $request->root() . ‘
    ‘;
    // 获取URL访问的ROOT地址
    echo ‘root with domain: ‘ . $request->root(true) . ‘
    ‘;
    // 获取URL地址中的PATH_INFO信息
    echo ‘pathinfo: ‘ . $request->pathinfo() . ‘
    ‘;
    // 获取URL地址中的PATH_INFO信息 不含后缀
    echo ‘pathinfo: ‘ . $request->path() . ‘
    ‘;
    // 获取URL地址中的后缀信息
    echo ‘ext: ‘ . $request->ext() . ‘
    ‘;

    输出结果:
    domain: http://tp5.com
    file: /index.php
    url: /index/index/hello.html?name=thinkphp
    url with domain: http://tp5.com/index/index/hello.html?name=thinkphp
    url without query: /index/index/hello.html
    root: root with domain: http://tp5.com
    pathinfo: index/index/hello.html
    pathinfo: index/index/hello
    ext: html

    参考:
    https://blog.csdn.net/ts3211/article/details/86536489