thinkphp5.1.35 URL生成怎样才能不默认带上域名

浏览:1109 发布日期:2019/04/08 分类:ThinkPHP5专区
URL生成url('Test/index');没有定义路由路由规则,生成结果:/index/Test/index.html定义路由规则Route::group('test', function () {
    Route::get('/read', 'Test/read');
    Route::get('/', 'Test/index');
})->ext('html');
生成结果http://tp51.dev.com/test.html我想要的结果:/test.html我查看完整手册上有句话:
域名生成
默认生成的URL地址是不带域名的,如果你采用了多域名部署或者希望生成带有域名的URL地址的话,就需要传入第四个参数,该参数有两种用法:
自动生成域名Url::build('index/blog/read', 'id=5', 'shtml', true);
url('index/blog/read', 'id=5', 'shtml', true);
最佳答案
评论() 相关
后面还有条评论,点击查看>>