1、浏览器地址栏有什么就显示什么
$uri = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
2、浏览器地址栏没有显示默认索引的时候也能获取到
$url = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; //完整url+参数
thinkphp5.1获取当前模块、控制器、方法
request()->module() . '/' . request()->controller() . '/' . request()->action();
tp5.1获取当前url地址 nginx重写有效
$url = request()->url(true); $url2 = str_replace('index.php?s=//','',$url);