可以在Providers/RouteServiceProvider.php 进行相关配置 注意 $this->namespace 默认为注释状态 ~~~ Route::prefix('app') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/app.php')); ~~~ middleware 中间件 ~~~ Route::middleware([])->group(function(){ Route::put('user-update','app\UserController@update'); Route::post('statistical-subscribe','app\StatisticalController@subscribe'); Route::post('statistical-cert','app\StatisticalController@cert'); Route::post('statistical-pay','app\StatisticalController@pay'); Route::post('statistical-product','app\StatisticalController@product'); Route::get('borrow-condition','app\BorrowController@condition'); Route::get('borrow-detail','app\BorrowController@detail'); Route::get('product-list','app\ProductController@list'); Route::any('pay','PayController@pay'); }); ~~~ 通用路由配置 ~~~ Route::group(['middleware'=>["check.token:app"]], function () { //中间件检查 (没有可以去掉) Route::any('/{controller}/{action}', function ($controller, $action) { $request = app('request'); $controller = 'app\\'.ucfirst($controller).'Controller'; $con = new $controller($request); if (preg_match('/^[a-zA-Z][a-zA-Z0-9_]+/is', $action)) { if (method_exists($con, $action)) { return $con->{$action}($request); } } die('No route found , Please check url parameters'); }); }); ~~~ ![](https://img.kancloud.cn/de/e4/dee4e091543b4f5dfcf268881a2e2a8e_808x251.png) 访问路径 http://xxxx.com/app/home/index